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.util.*;
  
  import static java.lang.Math.log;
  import static java.lang.Math.min;
  
  public class Main {
  
      //------------------------------------------CONSTANTS---------------------------------------------------------------
      public static final int MOD = (int) (1e9 + 7);
  
      //---------------------------------------------I/0------------------------------------------------------------------
  
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
  
          public FastReader()
          {
              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;
          }
      }
  
      public static void print(String s) {
          System.out.println(s);
      }
  
      public static void main(String[] args) {
          FastReader sc = new FastReader();
  
          int t = 1;
          t = sc.nextInt();
  
          for(int i = 0; i<t; i++) {
              System.out.println(solve(sc));
          }
      }
  
      //------------------------------------------------SOLVE-------------------------------------------------------------
  
      public static String solve(FastReader sc) {
          int n = sc.nextInt(); int[] a = new int[n];
          char[] c = new char[n];
          for (int i = 0; i<n; i++) {
              a[i] = sc.nextInt();
          }
          c = sc.next().toCharArray();
  
          boolean[] gotit = new boolean[n+1];
          List<Integer> blues = new ArrayList<>();
          List<Integer> reds = new ArrayList<>();
          for (int i=0; i<n; i++) {
              if (c[i] == 'B')
                  blues.add(a[i]);
              else
                  reds.add(a[i]);
          }
  
          Collections.sort(blues);
          Collections.sort(reds);
          Collections.reverse(reds);
          int idx = 1;
          for (int x: blues) {
              if (idx <= x) {
                  gotit[idx] = true;
                  idx++;
              } else {
                  return "NO";
              }
          }
          idx = n;
          for (int x: reds) {
              if (idx >= x) {
                  gotit[idx] = true;
                  idx--;
              } else {
                  return "NO";
              }
          }
  
          return "YES";
      }
  
      public static int firstNotDivisor(int n, int z) {
          for (int i = z; i>=1; i--) {
              if (n%i!=0)
                  return i;
          }
          return -1;
      }
  
      public static int factorial(int n) {
          if (n == 0)
              return 1;
          int fact = 1;
          for (int i = 2; i<=n; i++) {
              fact *= i;
          }
          return fact;
      }
  
      public static int maxFactorial(int n) {
          int k = 1;
          int fact = 1;
          while ((k+1)*fact < n) {
              k++;
              fact *= k;
          }
          return k;
      }
  
      public static boolean isPalindrome(String s) {
          for (int i = 0; i<s.length()/2; i++) {
              if (s.charAt(i) != s.charAt(s.length()-1-i))
                  return false;
          }
          return true;
      }
  
      //-----------------------------------------------FUNCTIONS----------------------------------------------------------
  
      public static String printArray(int[] a) {
          StringBuilder r = new StringBuilder("");
  
          for(int i = 0; i<a.length; i++) {
              r.append(a[i] + " ");
          }
          return r.toString();
      }
  
      public static <T> String printList(List<T> a) {
          StringBuilder r = new StringBuilder("");
  
          for (T x: a) {
              r.append(x.toString() + " ");
          }
          return r.toString();
      }
  
      // first element that is not less than target
      public static int lowerBound(int[] arr, int begin, int end, int target) {
          while(begin < end) {
              int mid = begin + (end - begin) / 2;
              // When the element is less than the mid target
              if(arr[mid] < target)
                  // begin to mid + 1, arr [begin] value is less than or equal target
                  begin = mid + 1;
                  // When the mid target element when greater than or equal
              else if(arr[mid] >= target)
                  end = mid;
          }
          return begin;
      }
  
      // first element that is greater than target
      public static int upperBound(int[] arr, int begin, int end, int target) {
          while(begin < end) {
              int mid = begin + (end - begin) / 2;
              if(arr[mid] <= target)
                  begin = mid + 1;
              else
                  end = mid;
          }
          return begin;
      }
  
      // generate permutations (call search and access through permutations)
      public static class Permutations {
          List<List<Integer>> permutations = new ArrayList<>();
          List<Integer> permutation = new ArrayList<>();
          boolean[] taken;
          int[] a;
  
          public Permutations(int[] a) {
              this.a = a;
              taken = new boolean[a.length];
          }
  
          void search() {
              if (permutation.size()==a.length) {
                  permutations.add(new ArrayList<>(permutation));
              } else {
                  for (int i = 0; i<a.length; i++) {
                      if (taken[i]) {
                          continue;
                      }
                      taken[i] = true;
                      permutation.add(a[i]);
                      search();
                      taken[i] = false;
                      permutation.remove(permutation.size()-1);
                  }
              }
          }
      }
  
      // generate subsets (call search and access subsets)
      public static class Subsets {
          List<List<Integer>> subsets = new ArrayList<>();
          List<Integer> subset = new ArrayList<>();
  
          void search(int[] a, int x) {
              if (x == a.length) {
                  subsets.add(new ArrayList<>(subset));
              } else {
                  subset.add(a[x]);
                  search(a, x+1);
                  subset.remove(subset.size() - 1);
                  search(a, x+1);
              }
          }
      }
  
      public static int gcd(int a, int b) {
          while (b != 0) {
              int t = b;
              b = a % b;
              a = t;
          }
          return a;
      }
  
      public static int lcm(int a, int b) {
          return (a*b)/gcd(a, b);
      }
  
      public static int[] prefixSum(int[] a) {
          int n = a.length;
          int[] ps = new int[n];
          ps[0] = a[0];
  
          for (int i = 1; i<n; i++) {
              ps[i] = ps[i-1] + a[i];
          }
  
          return ps;
      }
  
      public static int[][] prefixSum2D(int[][] a) {
          int n = a.length;
          int m = a[0].length;
          int[][] ps = new int[n][m];
          ps[0][0] = a[0][0];
  
          for (int j = 1; j<m; j++) {
              ps[0][j] = ps[0][j-1] + a[0][j];
          }
          for (int i = 1; i<n; i++) {
              ps[i][0] = ps[i-1][0] + a[i][0];
          }
  
          for (int i = 1; i<n; i++) {
              for (int j = 1; j<m; j++) {
                  ps[i][j] = ps[i-1][j] + ps[i][j-1] - ps[i-1][j-1] + a[i][j];
              }
          }
  
          return ps;
      }
  
      public static double log2(double a) {
          return log(a)/log(2);
      }
  
      //----------------------------------------DATA-STRUCTURES-----------------------------------------------------------
  
      // Range queries (i.e. RMQ) in O(1), others with functions in O(log n)
      public static class SparseTable {
          int[][] st;
          int n;
          int k;
  
          public SparseTable(int[] a) {
              n = a.length;
              k = (int) log2(n);
              st = new int[n][k+1];
  
              for (int i = 0; i<n; i++) {
                  st[i][0] = a[i];
              }
  
              // 1<<j == 2^j
              for (int j = 1; j<=k; j++) {
                  for (int i = 0; i + (1 << j) <= n; i++) {
                      st[i][j] = min(st[i][j-1], st[i + (1 << (j - 1))][j - 1]);
                  }
              }
          }
  
          //not always available O(log n) -- change the constructor to use it
          public long sumQuery(int l, int r) {
              long sum = 0;
              for (int j = k; j>=0; j--) {
                  if ((1 << j) <= r - l + 1) {
                      sum += st[l][j];
                      l += 1 << j;
                  }
              }
  
              return sum;
          }
  
          //always available O(1) -- change this and the constructor for rangeMaxQuery
          public int rangeMinQuery(int l, int r) {
              int j = (int) log2(r - l + 1);
              int min = min(st[l][j], st[r - (1 << j) + 1][j]);
              return min;
          }
  
      }
  
      //Range Sum Dynamic Queries O(log n)
      public static class BinaryIndexedTree {
  
          int[] bit;
  
          public BinaryIndexedTree(int[] a) {
              int n = a.length;
              bit = new int[n+1];
              // Store the actual values in BITree[]
              // using update()
              for(int i = 0; i < n; i++)
                  updateBit(i, a[i]);
          }
  
          // O(log n) update delta at index in the array (do it on the array and then call this function)
          public void updateBit(int index, int delta) {
              index += 1;
  
              while (index <= bit.length) {
                  bit[index] += delta;
  
                  index += index & (-index);
              }
          }
  
          // Computes sum a[0...index] in O(log n)
          public int getSum(int index) {
              int sum = 0;
  
              index += 1;
  
              while (index > 0) {
                  sum += bit[index];
  
                  index -= index & (-index);
              }
  
              return sum;
          }
      }
  
      public static class UnionFind {
  
          int[] link;
          int[] size;
  
          UnionFind(int n) {
              link = new int[n];
              size = new int[n];
              for (int i = 0; i<n; i++) {
                  link[i] = i;
                  size[i] = 1;
              }
          }
  
          int find(int x) {
              while (x != link[x]) x = link[x];
              return x;
          }
  
          boolean same(int a, int b) {
              return find(a) == find(b);
          }
  
          void unite(int a, int b) {
              a = find(a);
              b = find(b);
  
              if (size[a] < size[b]) {
                  int temp = a;
                  a = b;
                  b = temp;
              }
  
              size[a] += size[b];
              link[b] = a;
          }
      }
  
      public static class SegmentTree {
  
          int st[];
  
          public SegmentTree(int arr[]) {
              int n = arr.length;
  
              int x = (int) (Math.ceil(log2(n)));
  
              int maxSize = 2 * (int) Math.pow(2, x) - 1;
  
              st = new int[maxSize];
  
              build(arr, 0, n-1, 0);
          }
  
          int build(int arr[], int ss, int se, int si) {
              if (ss == se) {
                  st[si] = arr[ss];
                  return arr[ss];
              }
  
              int mid = ss + (se - ss) / 2; //ss+se/2
  
              st[si] = build(arr, ss, mid, si * 2 + 1) +
                      build(arr, mid + 1, se, si * 2 + 2);
              return st[si];
          }
  
          private int getSumUtil(int ss, int se, int l, int r, int si) {
              if (l <= ss && r >= se) {
                  return st[si];
              }
  
              if (se < l || ss > r) {
                  return 0;
              }
  
              int mid = ss + (se - ss) / 2;
              return getSumUtil(ss, mid, l, r, 2 * si + 1) +
                      getSumUtil(mid + 1, se, l, r, 2 * si + 2);
          }
  
          void updateValueUtil(int ss, int se, int i, int diff, int si) {
              if (i < ss || i > se) {
                  return;
              }
  
              st[si] = st[si] + diff;
              if (se != ss) {
                  int mid = ss + (se - ss) / 2;
                  updateValueUtil(ss, mid, i, diff, 2 * si + 1);
                  updateValueUtil(mid + 1, se, i, diff, 2 * si + 2);
              }
          }
  
          int getSum(int n, int l, int r) {
              if (l < 0 || r > n - 1 || l > r) {
                  return -1;
              }
  
              return getSumUtil(0, n-1, l, r, 0);
          }
  
          // don't do it directly on the array but use this function that will
          // do everything for you
          void updateValue(int arr[], int n, int i, int newValue) {
              if (i < 0 || i > n - 1) {
                  return;
              }
  
              int diff = newValue - arr[i];
  
              arr[i] = newValue;
  
              updateValueUtil(0, n - 1, i, diff, 0);
          }
      }
  
      // Similar to Pair in c++, non-null objects as parameters
      public static class Pair<T extends Comparable<T>, Q extends Comparable<Q>> implements Comparable<Pair<T, Q>>{
          T a;
          Q b;
  
          public Pair(T a, Q b) {
              this.a = a;
              this.b = b;
          }
  
          @Override
          public boolean equals(Object o) {
              if (this == o) return true;
              if (o == null || getClass() != o.getClass()) return false;
              Pair<?, ?> pair = (Pair<?, ?>) o;
              return a.equals(pair.a) && b.equals(pair.b);
          }
  
          @Override
          public int hashCode() {
              return Objects.hash(a, b);
          }
  
  
          @Override
          public int compareTo(Pair<T, Q> tqPair) {
              int compareA = this.a.compareTo(tqPair.a);
  
              if (compareA == 0) {
                  return this.b.compareTo(tqPair.b);
              } else {
                  return compareA;
              }
          }
      }
  
      // Uses Map + TreeSet to get the structure
      public static class OrderedMultiSet<T extends Comparable<T>> {
          private final TreeSet<T> set = new TreeSet<>();
          private final Map<T, Integer> frequencies = new HashMap<>();
          private int size = 0;
  
          public OrderedMultiSet() {}
  
          public OrderedMultiSet(List<T> a) {
              for (T x: a) {
                  this.add(x);
                  size++;
              }
          }
  
          public void add(T element) {
              set.add(element);
              if (!frequencies.containsKey(element)) {
                  frequencies.put(element, 0);
              }
              frequencies.put(element, frequencies.get(element) + 1);
              size++;
          }
  
          public boolean remove(T element) {
              if (frequencies.containsKey(element)) {
                  int x = frequencies.get(element);
                  x--;
                  if (x == 0) {
                      frequencies.remove(element);
                      set.remove(element);
                  } else {
                      frequencies.put(element, frequencies.get(element) - 1);
                  }
                  size--;
                  return true;
              }
              return false;
          }
  
          public int size() {
              return size;
          }
  
          public T first() {
              return set.first();
          }
  
          public T last() {
              return set.last();
          }
  
          public T pollFirst() {
              T t = set.first();
              remove(t);
              return t;
          }
  
          public T pollLast() {
              T t = set.last();
              set.
              remove(t);
              return t;
          }
      }
  }