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.ArrayList;
  import java.util.Collections;
  import java.util.StringTokenizer;
  
  public class Solve {
  
  	static long MOD = 998244353L;
  	static long INF = 1000_000_000_000_000L + 100;
  	static boolean isPrime[];
  
  	public static void main(String[] args) throws Exception {
  		Scanner sc = new Scanner();
  		PrintWriter pw = new PrintWriter(System.out);
  
  		int t = sc.nextInt();
  		while (t-- > 0) {
  			int n = sc.nextInt();
  			int a[] = sc.nextIntArray(n);
  			String str = sc.next();
  
  			ArrayList<Integer> B = new ArrayList<Integer>();
  
  			ArrayList<Integer> R = new ArrayList<Integer>();
  
  			for (int i = 0; i < n; i++) {
  				if (str.charAt(i) == 'R') {
  					R.add(a[i]);
  				} else {
  					B.add(a[i]);
  				}
  			}
  			Collections.sort(R);
  			Collections.sort(B);
  			int start = 1;
  			boolean ok = true;
  			for (int i = 0; i < B.size(); i++) {
  				if (B.get(i) >= start) {
  					start++;
  				} else {
  					ok = false;
  					break;
  				}
  			}
  			if (ok) {
  				for (int i = 0; i < R.size(); i++) {
  					if (R.get(i) <= start) {
  						start++;
  					} else {
  						ok = false;
  						break;
  					}
  				}
  
  				if (ok) {
  					pw.println("YES");
  				} else {
  					pw.println("NO");
  				}
  
  			} else {
  				pw.println("NO");
  			}
  
  		}
  		pw.flush();
  
  	}
  
  	static int LowerBound(int a[], int x, int start) { // x is the target value or key
  		int ans = -1;
  
  		int l = start, r = a.length;
  		while (l + 1 < r) {
  			System.out.println("lolk");
  
  			int m = (l + r) >>> 1;
  			if (a[m] >= x) {
  				ans = m;
  				r = m;
  			} else
  				l = m;
  		}
  		return ans;
  	}
  
  	static int UpperBound(int a[], int x, int start) {// x is the key or target value
  		int ans = -1;
  
  		int l = start, r = a.length;
  		while (l + 1 < r) {
  			int m = (l + r) >>> 1;
  			if (a[m] <= x) {
  				ans = m;
  				l = m;
  			} else
  				r = m;
  		}
  		return ans;
  	}
  
  	static public boolean[] sieve(int n) {
  		boolean prime[] = new boolean[n + 1];
  		for (int i = 0; i <= n; i++)
  			prime[i] = true;
  
  		for (int p = 2; p * p <= n; p++) {
  			// If prime[p] is not changed, then it is a
  			// prime
  			if (prime[p] == true) {
  				// Update all multiples of p
  				for (int i = p * p; i <= n; i += p)
  					prime[i] = false;
  			}
  		}
  		return prime;
  
  	}
  
  	public static ArrayList<Integer> primeFactors(int n) {
  		ArrayList<Integer> set = new ArrayList<Integer>();
  
  		// Print the number of 2s that divide n
  		while (n % 2 == 0) {
  			n /= 2;
  			set.add(2);
  		}
  
  		// n must be odd at this point. So we can
  		// skip one element (Note i = i +2)
  		for (int i = 3; i * i <= n; i += 2) {
  			// While i divides n, print i and divide n
  			while (n % i == 0) {
  				n /= i;
  				set.add(i);
  			}
  		}
  
  		if (n > 1)
  			set.add(n);
  
  		return set;
  
  	}
  
  	static long gcd(long a, long b) {
  		if (a == 0)
  			return b;
  		if (b == 0)
  			return a;
  
  		return gcd(b, a % b);
  
  	}
  
  	public static int[] swap(int data[], int left, int right) {
  
  		// Swap the data
  		int temp = data[left];
  		data[left] = data[right];
  		data[right] = temp;
  
  		// Return the updated array
  		return data;
  	}
  
  	public static long[] euclidExtended(long a, long b) {
  		if (b == 0) {
  			long ar[] = new long[] { 1, 0 };
  			return ar;
  		}
  		long ar[] = euclidExtended(b, a % b);
  		long temp = ar[0];
  		ar[0] = ar[1];
  		ar[1] = temp - (a / b) * ar[1];
  		return ar;
  	}
  
  	public static long modInverse(long a, long m) {
  		long ar[] = euclidExtended(a, m);
  		return ((ar[0] % m) + m) % m;
  	}
  
  	// Fermat Theorem
  	public static long ncr(int n, int r, long[] fact) {
  		if (n == r)
  			return 1;
  		if (r == 1)
  			return n;
  		if (n == 0 || r == 0)
  			return 1;
  		return (fact[n] * modInverse(((long) fact[n - r]) * fact[r], MOD)) % MOD;
  	}
  
  	static void sort(int[] a) {
  		ArrayList<Integer> l = new ArrayList<>();
  		for (int i : a)
  			l.add(i);
  		Collections.sort(l);
  		for (int i = 0; i < a.length; i++)
  			a[i] = l.get(i);
  	}
  
  }
  
  class Pair {
  	int x, y;
  
  	Pair(int x, int y) {
  		this.x = x;
  		this.y = y;
  	}
  
  }
  
  class SegTree {
  	int leftmost, rightmost, sum;
  	SegTree lChild, rChild;
  
  	public SegTree(int leftmost, int rightmost) {
  		this.leftmost = leftmost;
  		this.rightmost = rightmost;
  	}
  
  	public void update(int index, int val) {
  		sum++;
  		if (leftmost == rightmost) {
  			return;
  		}
  		if (lChild == null)
  			makeKids();
  		if (index <= lChild.rightmost)
  			lChild.update(index, val);
  		else
  			rChild.update(index, val);
  	}
  
  	public void makeKids() {
  		int mid = (leftmost + rightmost) / 2;
  		lChild = new SegTree(leftmost, mid);
  		rChild = new SegTree(mid + 1, rightmost);
  	}
  
  	public int query(int l, int r) {
  		if (l <= leftmost && r >= rightmost)
  			return sum;
  		if (l > rightmost || r < leftmost)
  			return 0;
  		if (lChild == null)
  			return 0;
  		return lChild.query(l, r) + rChild.query(l, r);
  	}
  }
  
  class UnionFind {
  	int[] p, rank, setSize;
  	int numSets;
  
  	public UnionFind(int N) {
  		p = new int[numSets = N];
  		rank = new int[N];
  		setSize = new int[N];
  		for (int i = 0; i < N; i++) {
  			p[i] = i;
  			setSize[i] = 1;
  		}
  	}
  
  	public int findSet(int i) {
  		return p[i] == i ? i : (p[i] = findSet(p[i]));
  	}
  
  	public boolean isSameSet(int i, int j) {
  		return findSet(i) == findSet(j);
  	}
  
  	public void unionSet(int i, int j) {
  		if (isSameSet(i, j))
  			return;
  		numSets--;
  		int x = findSet(i), y = findSet(j);
  		if (rank[x] > rank[y]) {
  			p[y] = x;
  			setSize[x] += setSize[y];
  		} else {
  			p[x] = y;
  			setSize[y] += setSize[x];
  			if (rank[x] == rank[y])
  				rank[y]++;
  		}
  	}
  
  	public int numDisjointSets() {
  		return numSets;
  	}
  
  	public int sizeOfSet(int i) {
  		return setSize[findSet(i)];
  	}
  }
  
  class Scanner {
  	BufferedReader br;
  	StringTokenizer st;
  
  	Scanner() {
  		br = new BufferedReader(new InputStreamReader(System.in));
  	}
  
  	String next() throws IOException {
  		while (st == null || !st.hasMoreElements())
  			st = new StringTokenizer(br.readLine());
  		return st.nextToken();
  	}
  
  	int nextInt() throws NumberFormatException, IOException {
  		return Integer.parseInt(next());
  	}
  
  	int[] nextIntArray(int n) throws NumberFormatException, IOException {
  		int a[] = new int[n];
  		for (int i = 0; i < n; i++)
  			a[i] = Integer.parseInt(next());
  		return a;
  	}
  
  	long nextLong() throws NumberFormatException, IOException {
  		return Long.parseLong(next());
  	}
  
  	long[] nextLongArray(int n) throws NumberFormatException, IOException {
  		long a[] = new long[n];
  		for (int i = 0; i < n; i++)
  			a[i] = Long.parseLong(next());
  		return a;
  	}
  
  	double nextDouble() throws NumberFormatException, IOException {
  		return Double.parseDouble(next());
  	}
  }