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.*;
  import java.util.*;
  
  public class Main {
  	static InputReader in = new InputReader(System.in);
  	static OutputWriter out = new OutputWriter(System.out);
  
  	public static void main(String[] args) throws IOException {
  		int t = i();
  		int c = 1;
  		sb = new StringBuilder();
  		while (t-- > 0) {
  //			sb.append("Case #" + c + ": ");
  			solve();
  			c++;
  		}
  		out.println(sb.toString());
  		out.close();
  
  	}
  
  	static int mod = 1000000007;
  	static StringBuilder sb;
  
  	private static void solve() {
  		int n = i();
  		int[] arr = readArray(n);
  		String s = s();
  		TreeMap<Integer, LinkedList<Integer>> b = new TreeMap<>();
  		TreeMap<Integer, LinkedList<Integer>> r = new TreeMap<>();
  		boolean res = true;
  		for (int i = 0; i < n; i++) {
  			if (s.charAt(i) == 'R') {
  				if (!r.containsKey(arr[i])) {
  					r.put(arr[i], new LinkedList<>());
  				}
  				r.get(arr[i]).add(i);
  				if (arr[i] > n) {
  					res = false;
  					break;
  				}
  			} else {
  				if (!b.containsKey(arr[i])) {
  					b.put(arr[i], new LinkedList<>());
  				}
  				b.get(arr[i]).add(i);
  				if (arr[i] < 1) {
  					res = false;
  					break;
  				}
  			}
  		}
  		for (int i = 1; i <= n && res; i++) {
  			if (!b.isEmpty()) {
  				int val = arr[b.get(b.firstKey()).remove()];
  				if (val < i) {
  					res = false;
  					break;
  				}
  				if (b.get(b.firstKey()).size() == 0) {
  					b.remove(b.firstKey());
  				}
  			} else {
  				int val = arr[r.get(r.firstKey()).remove()];
  				if (val > i) {
  					res = false;
  					break;
  				}
  				if (r.get(r.firstKey()).size() == 0) {
  					r.remove(r.firstKey());
  				}
  			}
  		}
  		if (res) {
  			sb.append("YES");
  		} else {
  			sb.append("NO");
  		}
  		sb.append("\n");
  	}
  
  	// Fenwick Tree
  	static class fenwickTree {
  		int n;
  		long[] farr;
  
  		fenwickTree(int n, long[] a) {
  			this.n = n;
  			farr = new long[n + 1];
  			for (int i = 0; i < n; i++) {
  				update(i + 1, a[i]);
  			}
  		}
  
  		void update(int i, long val) {
  			while (i < farr.length) {
  				farr[i] += val;
  				i += (i & -i);
  			}
  		}
  
  		long sum(int i) {
  			long sum = 0L;
  			while (i > 0) {
  				sum += farr[i];
  				i -= (i & -i);
  			}
  			return sum;
  		}
  	}
  
  // ****CLASS PAIR ************************************************
  //	static class Pair implements Comparable<Pair> {
  //		int sp;
  //		int ep;
  //
  //		Pair(int sp, int ep) {
  //			this.sp = sp;
  //			this.ep = ep;
  //		}
  //
  //		public int compareTo(Pair o) {
  //			return this.sp - o.sp;
  //		}
  //
  //	}
  
  	static class Pair implements Comparable<Pair> {
  		char ch;
  		ArrayList<Integer> idxs;
  
  		Pair(char ch, ArrayList<Integer> idxs) {
  			this.ch = ch;
  			this.idxs = idxs;
  		}
  
  		public int compareTo(Pair o) {
  			return o.idxs.size() - this.idxs.size();
  		}
  
  	}
  
  	static class Edge implements Comparable<Edge> {
  		int u;
  		int v;
  		int wt;
  
  		Edge(int u, int v, int wt) {
  			this.u = u;
  			this.v = v;
  			this.wt = wt;
  		}
  
  		public int compareTo(Edge o) {
  			return this.wt - o.wt;
  		}
  	}
  
  // *************Disjoint Set Union*********//
  	static class dsu {
  		int[] par;
  		int[] rank;
  
  		dsu(int n) {
  			par = new int[n + 1];
  			rank = new int[n + 1];
  			for (int i = 0; i <= n; i++) {
  				par[i] = i;
  				rank[i] = 1;
  			}
  		}
  
  		int find(int a) {
  			if (par[a] == a) {
  				return a;
  			}
  			int x = find(par[a]);
  			par[a] = x;
  			return x;
  		}
  
  		boolean union(int a, int b) {
  			int pa = find(a);
  			int pb = find(b);
  			if (pa == pb) {
  				return false;
  			}
  			if (rank[pa] > rank[pb]) {
  				par[pb] = pa;
  			} else if (rank[pb] > rank[pa]) {
  				par[pa] = pb;
  			} else {
  				par[pa] = pb;
  				rank[pb]++;
  			}
  			return true;
  		}
  
  	}
  
  	// **************NCR%P******************
  	static long ncr(int n, int r) {
  		if (r > n)
  			return (long) 0;
  		long[] fact = new long[(int) 1e6 + 10];
  		fact[0] = fact[1] = 1;
  		for (int i = 2; i < fact.length; i++) {
  			fact[i] = ((long) (i % mod) * (long) (fact[i - 1] % mod)) % mod;
  		}
  		long res = fact[n] % mod;
  		res = ((long) (res % mod) * (long) (p(fact[r], mod - 2) % mod)) % mod;
  		res = ((long) (res % mod) * (long) (p(fact[n - r], mod - 2) % mod)) % mod;
  		return res;
  	}
  
  	static ArrayList<Integer> divisors(int n) {
  		ArrayList<Integer> al = new ArrayList<>();
  		for (int i = 1; i * i <= n; i++) {
  			if (n % i == 0) {
  				if (n == i * i) {
  					al.add(i);
  				} else {
  					al.add(i);
  					al.add(n / i);
  				}
  			}
  		}
  		Collections.sort(al);
  		return al;
  	}
  
  	static long p(long x, long y)// POWER FXN //
  	{
  		if (y == 0)
  			return 1;
  
  		long res = 1;
  		while (y > 0) {
  			if (y % 2 == 1) {
  				res = (res * x) % mod;
  				y--;
  			}
  
  			x = (x * x) % mod;
  			y = y / 2;
  
  		}
  		return res % mod;
  	}
  
  	private static boolean pow2(int i) {
  		return (i & (i - 1)) == 0;
  	}
  
  	private static void sort(int[] arr) {
  		int n = arr.length;
  		ArrayList<Integer> res = new ArrayList<>();
  		for (int a : arr) {
  			res.add(a);
  		}
  		Collections.sort(res);
  		for (int i = 0; i < n; i++) {
  			arr[i] = res.get(i);
  		}
  	}
  
  	private static void sort(long[] arr) {
  		int n = arr.length;
  		ArrayList<Long> res = new ArrayList<>();
  		for (long a : arr) {
  			res.add(a);
  		}
  		Collections.sort(res);
  		for (int i = 0; i < n; i++) {
  			arr[i] = res.get(i);
  		}
  	}
  
  	private static void revSort(int[] arr) {
  		int n = arr.length;
  		ArrayList<Integer> res = new ArrayList<>();
  		for (int a : arr) {
  			res.add(a);
  		}
  		Collections.sort(res, Collections.reverseOrder());
  		for (int i = 0; i < n; i++) {
  			arr[i] = res.get(i);
  		}
  	}
  
  	private static ArrayList<Integer> sieveOfEratosthenes(int n) {
  		boolean[] arr = new boolean[n + 1];
  
  		arr[0] = arr[1] = true;
  		for (int i = 2; i * i <= n; i++) {
  			if (!arr[i]) {
  				for (int j = i * i; j <= n; j += i) {
  					arr[j] = true;
  				}
  			}
  		}
  		ArrayList<Integer> primes = new ArrayList<>();
  		for (int i = 2; i <= n; i++) {
  			if (!arr[i]) {
  				primes.add(i);
  			}
  		}
  		return primes;
  	}
  
  	private static ArrayList<Integer> segmentedSieve(int s, int e) {
  		int len = (int) (Math.sqrt(e) + 1);
  		ArrayList<Integer> primes = sieveOfEratosthenes(len);
  		boolean[] arr2 = new boolean[e - s + 1];
  		if (s == 1) {
  			arr2[0] = true;
  		}
  		ArrayList<Integer> res = new ArrayList<>();
  		for (int p : primes) {
  
  			int st = (int) (p * (Math.ceil((double) s / p)));
  			if (st < s) {
  				st += p;
  			}
  			if (st == p) {
  				st += p;
  			}
  			for (int i = st; i <= e; i += p) {
  				arr2[i - s] = true;
  			}
  		}
  		for (int i = 0; i < arr2.length; i++) {
  			if (!arr2[i]) {
  				res.add(i + s);
  			}
  		}
  		return res;
  	}
  
  	private static long pow(int n, int k) {
  		long res = 1;
  		long num = (long) n;
  		while (k > 0) {
  			if ((k & 1) == 1) {
  				res = (res * num) % mod;
  			}
  			k /= 2;
  			num = num * num % mod;
  		}
  		return res;
  	}
  
  	private static int countDigits(int n) {
  		int c = 0;
  		while (n != 0) {
  			c++;
  			n /= 10;
  		}
  		return c;
  	}
  
  	private static boolean palindrome(String str) {
  		int s = 0;
  		int e = str.length() - 1;
  		while (s < e) {
  			if (str.charAt(s) != str.charAt(e)) {
  				return false;
  			}
  			s++;
  			e--;
  		}
  		return true;
  	}
  
  	private static void reverse(int[] arr, int s, int e) {
  		while (s < e) {
  			int temp = arr[s];
  			arr[s++] = arr[e];
  			arr[e--] = temp;
  		}
  	}
  
  	private static int getMax(int[] arr, int s, int e) {
  		int maxi = s;
  		for (int i = s + 1; i <= e; i++) {
  			if (arr[i] > arr[maxi]) {
  				maxi = i;
  			}
  		}
  		return maxi;
  	}
  
  	private static int getMin(int[] arr, int s, int e) {
  		int mini = s;
  		for (int i = s + 1; i <= e; i++) {
  			if (arr[i] < arr[mini]) {
  				mini = i;
  			}
  		}
  		return mini;
  	}
  
  	// ******LOWEST COMMON MULTIPLE************************
  	private static long lcm(long n1, long n2) {
  		return (n1 * n2) / gcd(n1, n2);
  	}
  
  	private static int lcm(int n1, int n2) {
  		return (n1 * n2) / gcd(n1, n2);
  	}
  
  	// ***********GCD*****************
  	private static long gcd(long num1, long num2) {
  		if (num2 == 0) {
  			return num1;
  		}
  		return gcd(num2, num1 % num2);
  	}
  
  	private static int gcd(int num1, int num2) {
  		if (num2 == 0) {
  			return num1;
  		}
  		return gcd(num2, num1 % num2);
  	}
  
  	// **************PRIME FACTORIZE **********************************//
  	static TreeMap<Long, Long> prime(long n) {
  		TreeMap<Long, Long> h = new TreeMap<>();
  		long num = n;
  		for (int i = 2; i <= Math.sqrt(num); i++) {
  			if (n % i == 0) {
  				long nt = 0L;
  				while (n % i == 0) {
  					n = n / i;
  					nt++;
  				}
  				h.put(i * 1L, nt);
  			}
  		}
  		if (n != 1)
  			h.put(n, 1L);
  		return h;
  
  	}
  
  	static class InputReader {
  		private InputStream stream;
  		private byte[] buf = new byte[1024];
  		private int curChar;
  		private int numChars;
  		private SpaceCharFilter filter;
  
  		public InputReader(InputStream stream) {
  			this.stream = stream;
  		}
  
  		public int read() {
  			if (numChars == -1)
  				throw new InputMismatchException();
  			if (curChar >= numChars) {
  				curChar = 0;
  				try {
  					numChars = stream.read(buf);
  				} catch (IOException e) {
  					throw new InputMismatchException();
  				}
  				if (numChars <= 0)
  					return -1;
  			}
  			return buf[curChar++];
  		}
  
  		public int Int() {
  			int c = read();
  			while (isSpaceChar(c))
  				c = read();
  			int sgn = 1;
  			if (c == '-') {
  				sgn = -1;
  				c = read();
  			}
  			int res = 0;
  			do {
  				if (c < '0' || c > '9')
  					throw new InputMismatchException();
  				res *= 10;
  				res += c - '0';
  				c = read();
  			} while (!isSpaceChar(c));
  			return res * sgn;
  		}
  
  		public String String() {
  			int c = read();
  			while (isSpaceChar(c))
  				c = read();
  			StringBuilder res = new StringBuilder();
  			do {
  				res.appendCodePoint(c);
  				c = read();
  			} while (!isSpaceChar(c));
  			return res.toString();
  		}
  
  		public boolean isSpaceChar(int c) {
  			if (filter != null)
  				return filter.isSpaceChar(c);
  			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
  		}
  
  		public String next() {
  			return String();
  		}
  
  		public interface SpaceCharFilter {
  			public boolean isSpaceChar(int ch);
  		}
  	}
  
  	static class OutputWriter {
  		private final PrintWriter writer;
  
  		public OutputWriter(OutputStream outputStream) {
  			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
  		}
  
  		public OutputWriter(Writer writer) {
  			this.writer = new PrintWriter(writer);
  		}
  
  		public void print(Object... objects) {
  			for (int i = 0; i < objects.length; i++) {
  				if (i != 0)
  					writer.print(' ');
  				writer.print(objects[i]);
  			}
  		}
  
  		public void println(Object... objects) {
  			print(objects);
  			writer.println();
  		}
  
  		public void close() {
  			writer.close();
  		}
  
  		public void flush() {
  			writer.flush();
  		}
  	}
  
  //*****************INPUT PATTERN******************************************
  	public static int i() {
  		return in.Int();
  	}
  
  	public static long l() {
  		String s = in.String();
  		return Long.parseLong(s);
  	}
  
  	public static String s() {
  		return in.String();
  	}
  
  	public static int[] readArray(int n) {
  		int A[] = new int[n];
  		for (int i = 0; i < n; i++) {
  			A[i] = i();
  		}
  		return A;
  	}
  
  	public static long[] readArray(long n) {
  		long A[] = new long[(int) n];
  		for (int i = 0; i < n; i++) {
  			A[i] = l();
  		}
  		return A;
  	}
  
  }
  