description: You are given an array of integers a of length n. The elements of the array can be either different or the same. 
  
  Each element of the array is colored either blue or red. There are no unpainted elements in the array. One of the two operations described below can be applied to an array in a single step:
  
    * either you can select any blue element and decrease its value by 1; 
    * or you can select any red element and increase its value by 1. 
  
  
  
  Situations in which there are no elements of some color at all are also possible. For example, if the whole array is colored blue or red, one of the operations becomes unavailable.
  
  Determine whether it is possible to make 0 or more steps such that the resulting array is a permutation of numbers from 1 to n?
  
  In other words, check whether there exists a sequence of steps (possibly empty) such that after applying it, the array a contains in some order all numbers from 1 to n (inclusive), each exactly once.
  
  Input
  
  The first line contains an integer t (1 ≤ t ≤ 10^4) — the number of input data sets in the test.
  
  The description of each set of input data consists of three lines. The first line contains an integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the original array a. The second line contains n integers a_1, a_2, ..., a_n (-10^9 ≤ a_i ≤ 10^9) — the array elements themselves.
  
  The third line has length n and consists exclusively of the letters 'B' and/or 'R': ith character is 'B' if a_i is colored blue, and is 'R' if colored red.
  
  It is guaranteed that the sum of n over all input sets does not exceed 2 ⋅ 10^5.
  
  Output
  
  Print t lines, each of which contains the answer to the corresponding test case of the input. Print YES as an answer if the corresponding array can be transformed into a permutation, and NO otherwise.
  
  You can print the answer in any case (for example, the strings yEs, yes, Yes, and YES will be recognized as a positive answer).
  
  Example
  
  Input
  
  
  8
  4
  1 2 5 2
  BRBR
  2
  1 1
  BB
  5
  3 1 4 2 5
  RBRRB
  5
  3 1 3 1 3
  RBRRB
  5
  5 1 5 1 5
  RBRRB
  4
  2 2 2 2
  BRBR
  2
  1 -2
  BR
  4
  -2 -1 4 0
  RRRR
  
  
  Output
  
  
  YES
  NO
  YES
  YES
  NO
  YES
  YES
  YES
  
  Note
  
  In the first test case of the example, the following sequence of moves can be performed:
  
    * choose i=3, element a_3=5 is blue, so we decrease it, we get a=[1,2,4,2]; 
    * choose i=2, element a_2=2 is red, so we increase it, we get a=[1,3,4,2]; 
    * choose i=3, element a_3=4 is blue, so we decrease it, we get a=[1,3,3,2]; 
    * choose i=2, element a_2=2 is red, so we increase it, we get a=[1,4,3,2]. 
  
  
  
  We got that a is a permutation. Hence the answer is YES.
solution: 
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.*;
  
  
  public class Main {
  
  	static long mod = 1_000_000_007;
  
  	public static void main(String[] args) {
  
  		FastScanner f = new FastScanner();
  		PrintWriter p = new PrintWriter(System.out);
  		int t=f.nextInt();
  		while(t-->0) {
  			int n=f.nextInt();
  			int arr[]=new int[n];
  			for(int i=0;i<n;i++) {
  				arr[i]=f.nextInt();
  			}
  			char c[]=f.next().toCharArray();
  			ArrayList<Integer> blue=new ArrayList<>();
  			ArrayList<Integer> red=new ArrayList<>(); 
  			for(int i=0;i<n;i++) {
  				if(c[i]=='B') {
  					blue.add(arr[i]);
  				}else {
  					red.add(arr[i]);
  				}
  			}
  			
  			Collections.sort(blue);
  			Collections.sort(red);
  			HashSet<Integer> hashSet=new HashSet<>();
  			int curr=1;
  			for(int i=0;i<blue.size();i++) {
  				int num=blue.get(i);
  				if(curr<=num) hashSet.add(curr);
  				curr++;
  			}
  			for(int i=0;i<red.size();i++) {
  				int num=red.get(i);
  				if(curr>=num) hashSet.add(curr);
  				curr++;
  			}
  			
  			if(hashSet.size()==n) {
  				p.println("YES");
  			}else {
  				p.println("NO");
  			}
  		}
  		p.close();
  
  	}
  
  
  	
  	
  	
  	
  
  	
  
  //-----------------------------------------------------------------------------------------------------------------------------------------------------------------
  
  	static int offx[] = { -1, -1, -1, 0, 1, 1, 1, 0 };
  	static int offy[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
  
  	static class FastScanner {
  		BufferedReader br;
  		StringTokenizer st;
  
  		public FastScanner() {
  			br = new BufferedReader(new InputStreamReader(System.in));
  		}
  
  		String next() {
  			while (st == null || !st.hasMoreElements()) {
  				try {
  					st = new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					e.printStackTrace();
  				}
  			}
  			return st.nextToken();
  		}
  
  		int nextInt() {
  			return Integer.parseInt(next());
  		}
  
  		long nextLong() {
  			return Long.parseLong(next());
  		}
  
  		double nextDouble() {
  			return Double.parseDouble(next());
  		}
  
  		String nextLine() {
  			String str = "";
  			try {
  				str = br.readLine();
  			} catch (IOException e) {
  				e.printStackTrace();
  			}
  			return str;
  		}
  	}
  
  	static long add(long x, long y) {
  		x += y;
  		if (x >= mod)
  			return (x % mod);
  		return x;
  	}
  
  	static long sub(long x, long y) {
  		x -= y;
  		if (x < 0)
  			return (x + mod);
  		return x;
  	}
  
  	static long mul(long x, long y) {
  		return (x * y) % mod;
  	}
  
  	static long bin_pow(long x, long p) {
  		if (p == 0)
  			return 1;
  		if ((p & 1) != 0)
  			return mul(x, bin_pow(x, p - 1));
  		return bin_pow(mul(x, x), p / 2);
  	}
  
  	static long rev(long x) {
  		return bin_pow(x, mod - 2);
  	}
  
  	static long div(long x, long y) {
  		return mul(x, rev(y));
  	}
  
  	// will work till array size of 65537---fastest sorting time
  	static long[] radixSort(long[] f) {
  		return radixSort(f, f.length);
  	}
  
  	static long[] radixSort(long[] f, int n) {
  		long[] to = new long[n];
  		{
  			int[] b = new int[65537];
  			for (int i = 0; i < n; i++)
  				b[1 + (int) (f[i] & 0xffff)]++;
  			for (int i = 1; i <= 65536; i++)
  				b[i] += b[i - 1];
  			for (int i = 0; i < n; i++)
  				to[b[(int) (f[i] & 0xffff)]++] = f[i];
  			long[] d = f;
  			f = to;
  			to = d;
  		}
  		{
  			int[] b = new int[65537];
  			for (int i = 0; i < n; i++)
  				b[1 + (int) (f[i] >>> 16 & 0xffff)]++;
  			for (int i = 1; i <= 65536; i++)
  				b[i] += b[i - 1];
  			for (int i = 0; i < n; i++)
  				to[b[(int) (f[i] >>> 16 & 0xffff)]++] = f[i];
  			long[] d = f;
  			f = to;
  			to = d;
  		}
  		{
  			int[] b = new int[65537];
  			for (int i = 0; i < n; i++)
  				b[1 + (int) (f[i] >>> 32 & 0xffff)]++;
  			for (int i = 1; i <= 65536; i++)
  				b[i] += b[i - 1];
  			for (int i = 0; i < n; i++)
  				to[b[(int) (f[i] >>> 32 & 0xffff)]++] = f[i];
  			long[] d = f;
  			f = to;
  			to = d;
  		}
  		{
  			int[] b = new int[65537];
  			for (int i = 0; i < n; i++)
  				b[1 + (int) (f[i] >>> 48 & 0xffff)]++;
  			for (int i = 1; i <= 65536; i++)
  				b[i] += b[i - 1];
  			for (int i = 0; i < n; i++)
  				to[b[(int) (f[i] >>> 48 & 0xffff)]++] = f[i];
  			long[] d = f;
  			f = to;
  			to = d;
  		}
  		return f;
  	}
  
  	// Function to sort an array using quick sort algorithm.
  	static void quickSort(long arr[], int low, int high) {
  		if (low < high) {
  			int p = partition(arr, low, high);
  			quickSort(arr, low, p - 1);
  			quickSort(arr, p + 1, high);
  		}
  	}
  
  	static int partition(long arr[], int low, int high) {
  		long pivot = arr[high];
  		int i = low - 1;
  		for (int j = low; j < high; j++) {
  			if (arr[j] < pivot) {
  				i++;
  				long temp = arr[i];
  				arr[i] = arr[j];
  				arr[j] = temp;
  			}
  		}
  		long temp = arr[i + 1];
  		arr[i + 1] = arr[high];
  		arr[high] = temp;
  
  		return i + 1;
  	}
  
  	/// Ceils
  	static long ceil(long x, long m) {
  		long res = x / m;
  		if (x % m != 0) {
  			res++;
  		}
  		return res;
  	}
  
  	// ------------------------------------------------------------------------------------------------
  	// makes the prefix sum array
  	static long[] prefixSum(long arr[], int n) {
  		long psum[] = new long[n];
  		psum[0] = arr[0];
  		for (int i = 1; i < n; i++) {
  			psum[i] = psum[i - 1] + arr[i];
  		}
  		return psum;
  	}
  	// ------------------------------------------------------------------------------------------------
  
  	// makes the suffix sum array
  	static long[] suffixSum(long arr[], int n) {
  		long ssum[] = new long[n];
  		ssum[n - 1] = arr[n - 1];
  		for (int i = n - 2; i >= 0; i--) {
  			ssum[i] = ssum[i + 1] + arr[i];
  		}
  		return ssum;
  	}
  
  //------------------------------------------------------------------------------------------
  	// BINARY EXPONENTIATION OF A NUMBER MODULO M FASTER METHOD WITHOUT RECURSIVE
  	// OVERHEADS
  //	static long m = (long) (1e9 + 7);
  
  	static long binPower(long a, long n, long m) {
  		if (n == 0)
  			return 1;
  		long res = 1;
  		while (n > 0) {
  			if ((n & 1) != 0) {
  				res *= a;
  			}
  			a *= a;
  			n >>= 1;
  		}
  		return res;
  	}
  
  //-------------------------------------------------------------------------------------------
  
  	// gcd
  	static long gcd(long a, long b) {
  		return b == 0 ? a : gcd(b, a % b);
  	}
  
  //------------------------------------------------------------------------------------------
  
  	// lcm
  	static long lcm(long a, long b) {
  		return a / gcd(a, b) * b;
  	}
  
  	// ------------------------------------------------------------------------------------------
  	// BRIAN KERNINGHAM TO CHECK NUMBER OF SET BITS
  	// O(LOGn)
  	static int setBits(int n) {
  		int count = 0;
  		while (n > 0) {
  			n = n & (n - 1);
  			count++;
  		}
  		return count;
  	}
  //------------------------------------------------------------------------------------------
  
  	// ------------------------------------------------------------------------------------------
  	// 0 based indexing
  	static boolean KthBitSet(int n, int k) {
  		int mask = 1;
  		mask = mask <<= k;
  		if ((mask & n) != 0)
  			return true;
  		else
  			return false;
  	}
  
  //------------------------------------------------------------------------------------------
  
  	// EXTENDED EUCLIDEAN THEOREM
  	// TO REPRESENT GCD IN TERMS OF A AND B
  	// gcd(a,b) = a.x + b.y where x and y are integers
  
  	static long x = -1;
  	static long y = -1;
  
  	static long gcdxy(long a, long b) {
  		if (b == 0) {
  			x = 1;
  			y = 0;
  			return a;
  		} else {
  			long d = gcdxy(b, a % b);
  			long x1 = y;
  			long y1 = x - (a / b) * y;
  			x = x1;
  			y = y1;
  
  			return d;
  		}
  	}
  
  //-------------------------------------------------------------------------------------------------
  }
  