description: You are given a matrix, consisting of n rows and m columns. The j-th cell of the i-th row contains an integer a_{ij}.
  
  First, you have to color each row of the matrix either red or blue in such a way that at least one row is colored red and at least one row is colored blue.
  
  Then, you have to choose an integer k (1 ≤ k < m) and cut the colored matrix in such a way that the first k columns become a separate matrix (the left matrix) and the last m-k columns become a separate matrix (the right matrix).
  
  The coloring and the cut are called perfect if two properties hold: 
  
    * every red cell in the left matrix contains an integer greater than every blue cell in the left matrix; 
    * every blue cell in the right matrix contains an integer greater than every red cell in the right matrix. 
  
  
  
  Find any perfect coloring and cut, or report that there are none.
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.
  
  Then the descriptions of t testcases follow.
  
  The first line of each testcase contains two integers n and m (2 ≤ n, m ≤ 5 ⋅ 10^5; n ⋅ m ≤ 10^6) — the number of rows and the number of columns in the matrix, respectively.
  
  The i-th of the next n lines contains m integers a_{i1}, a_{i2}, ..., a_{im} (1 ≤ a_{ij} ≤ 10^6).
  
  The sum of n ⋅ m over all testcases doesn't exceed 10^6.
  
  Output
  
  For each testcase print an answer. If there are no perfect colorings and cuts in the matrix, then print "NO".
  
  Otherwise, first, print "YES". Then a string, consisting of n characters: the i-th character should be 'R' if the i-th row is colored red and 'B' if it's colored blue. The string should contain at least one 'R' and at least one 'B'. Finally, print an integer k (1 ≤ k < m) — the number of columns from the left that are cut.
  
  Example
  
  Input
  
  
  3
  5 5
  1 5 8 8 7
  5 2 1 4 3
  1 6 9 7 5
  9 3 3 3 2
  1 7 9 9 8
  3 3
  8 9 8
  1 5 3
  7 5 7
  2 6
  3 3 3 2 2 2
  1 1 1 4 4 4
  
  
  Output
  
  
  YES
  BRBRB 1
  NO
  YES
  RB 3
  
  Note
  
  The coloring and the cut for the first testcase:
  
  <image>
solution: /*
  stream Butter!
  eggyHide eggyVengeance
  I need U
  xiao rerun when
  */
  import static java.lang.Math.*;
  import java.util.*;
  import java.io.*;
  import java.math.*;
  
  public class x1606D
  {
      public static void main(String hi[]) throws Exception
      {
          FastScanner infile = new FastScanner();
          int T = infile.nextInt();
          StringBuilder sb = new StringBuilder();
          tc:while(T-->0)
          {
              int N = infile.nextInt();
              int M = infile.nextInt();
              int[][] grid = new int[N][M];
              for(int r=0; r < N; r++)
                  grid[r] = infile.nextInts(M);
              int[][] prefixMax = new int[N][M];
              int[][] prefixMin = new int[N][M];
              for(int r=0; r < N; r++)
              {
                  prefixMax[r][0] = prefixMin[r][0] = grid[r][0];
                  for(int c=1; c < M; c++)
                  {
                      prefixMax[r][c] = max(prefixMax[r][c-1], grid[r][c]);
                      prefixMin[r][c] = min(prefixMin[r][c-1], grid[r][c]);
                  }
              }
              int[][] suffixMax = new int[N][M];
              int[][] suffixMin = new int[N][M];
              for(int r=0; r < N; r++)
              {
                  suffixMax[r][M-1] = suffixMin[r][M-1] = grid[r][M-1];
                  for(int c=M-2; c >= 0; c--)
                  {
                      suffixMax[r][c] = max(suffixMax[r][c+1], grid[r][c]);
                      suffixMin[r][c] = min(suffixMin[r][c+1], grid[r][c]);
                  }
              }
              for(int cut=0; cut < M-1; cut++)
              {
                  ArrayList<Integer> ls = new ArrayList<Integer>();
                  for(int r=0; r < N; r++)
                      ls.add(r);
                  int lmaocut = cut;
                  Collections.sort(ls, (x,y) -> {
                      return prefixMax[x][lmaocut]-prefixMax[y][lmaocut];
                  });
                  int redMins = prefixMin[ls.get(N-1)][cut];
                  boolean[] isRed = new boolean[N];
                  isRed[ls.get(N-1)] = true;
                  //precomp the right side stuff
                  int[] rightRed = new int[N];
                  rightRed[N-1] = suffixMax[ls.get(N-1)][cut+1];
                  for(int i=N-2; i >= 0; i--)
                      rightRed[i] = max(rightRed[i+1], suffixMax[ls.get(i)][cut+1]);
                  int[] rightBlue = new int[N];
                  rightBlue[0] = suffixMin[ls.get(0)][cut+1];
                  for(int i=1; i < N; i++)
                      rightBlue[i] = min(rightBlue[i-1], suffixMin[ls.get(i)][cut+1]);
                  for(int blue=N-2; blue >= 0; blue--)
                  {
                      if(prefixMax[ls.get(blue)][cut] < redMins)
                      {
                          //check the right matrix
                          int maxRed = rightRed[blue+1];
                          int minBlue = rightBlue[blue];
                          if(maxRed < minBlue)
                          {
                              sb.append("YES\n");
                              for(int i=0; i < N; i++)
                              {
                                  if(isRed[i])
                                      sb.append("R");
                                  else
                                      sb.append("B");
                              }
                              sb.append(" "+(cut+1)+"\n");
                              continue tc;
                          }
                      }
                      redMins = min(redMins, prefixMin[ls.get(blue)][cut]);
                      isRed[ls.get(blue)] = true;
                  }
              }
              sb.append("NO\n");
          }
          System.out.print(sb);
      }
  }
  /*
  think about the first column
  If row r is colored red, all r2 with grid[r2][0] > grid[r][0] will also be red
  prefix max?
  for each possible cut, there are only N possible colorings for red rows
  
  For each cut, figure out the prefix maxes for each row and sort them by it
  Then just check if the suffix mins work
   */
  class FastScanner
  {
      //I don't understand how this works lmao
      private int BS = 1 << 16;
      private char NC = (char) 0;
      private byte[] buf = new byte[BS];
      private int bId = 0, size = 0;
      private char c = NC;
      private double cnt = 1;
      private BufferedInputStream in;
  
      public FastScanner() {
          in = new BufferedInputStream(System.in, BS);
      }
  
      public FastScanner(String s) {
          try {
              in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
          } catch (Exception e) {
              in = new BufferedInputStream(System.in, BS);
          }
      }
  
      private char getChar() {
          while (bId == size) {
              try {
                  size = in.read(buf);
              } catch (Exception e) {
                  return NC;
              }
              if (size == -1) return NC;
              bId = 0;
          }
          return (char) buf[bId++];
      }
  
      public int nextInt() {
          return (int) nextLong();
      }
  
      public int[] nextInts(int N) {
          int[] res = new int[N];
          for (int i = 0; i < N; i++) {
              res[i] = (int) nextLong();
          }
          return res;
      }
  
      public long[] nextLongs(int N) {
          long[] res = new long[N];
          for (int i = 0; i < N; i++) {
              res[i] = nextLong();
          }
          return res;
      }
  
      public long nextLong() {
          cnt = 1;
          boolean neg = false;
          if (c == NC) c = getChar();
          for (; (c < '0' || c > '9'); c = getChar()) {
              if (c == '-') neg = true;
          }
          long res = 0;
          for (; c >= '0' && c <= '9'; c = getChar()) {
              res = (res << 3) + (res << 1) + c - '0';
              cnt *= 10;
          }
          return neg ? -res : res;
      }
  
      public double nextDouble() {
          double cur = nextLong();
          return c != '.' ? cur : cur + nextLong() / cnt;
      }
  
      public double[] nextDoubles(int N) {
          double[] res = new double[N];
          for (int i = 0; i < N; i++) {
              res[i] = nextDouble();
          }
          return res;
      }
  
      public String next() {
          StringBuilder res = new StringBuilder();
          while (c <= 32) c = getChar();
          while (c > 32) {
              res.append(c);
              c = getChar();
          }
          return res.toString();
      }
  
      public String nextLine() {
          StringBuilder res = new StringBuilder();
          while (c <= 32) c = getChar();
          while (c != '\n') {
              res.append(c);
              c = getChar();
          }
          return res.toString();
      }
  
      public boolean hasNext() {
          if (c > 32) return true;
          while (true) {
              c = getChar();
              if (c == NC) return false;
              else if (c > 32) return true;
          }
      }
  }