description: The robot is located on a checkered rectangular board of size n × m (n rows, m columns). The rows in the board are numbered from 1 to n from top to bottom, and the columns — from 1 to m from left to right.
  
  The robot is able to move from the current cell to one of the four cells adjacent by side.
  
  The sequence of commands s executed by the robot is given. Each command is denoted by one of the symbols 'L', 'R', 'D' or 'U', and triggers the movement to left, right, down or up, respectively.
  
  The robot can start its movement in any cell. The robot executes the commands starting from the first one, strictly in the order in which they are listed in s. If the robot moves beyond the edge of the board, it falls and breaks. A command that causes the robot to break is not considered successfully executed.
  
  The robot's task is to execute as many commands as possible without falling off the board. For example, on board 3 × 3, if the robot starts a sequence of actions s="RRDLUU" ("right", "right", "down", "left", "up", "up") from the central cell, the robot will perform one command, then the next command will force him to cross the edge. If the robot starts moving from the cell (2, 1) (second row, first column) then all commands will be executed successfully and the robot will stop at the cell (1, 2) (first row, second column).
  
  <image> The robot starts from cell (2, 1) (second row, first column). It moves right, right, down, left, up, and up. In this case it ends in the cell (1, 2) (first row, second column).
  
  Determine the cell from which the robot should start its movement in order to execute as many commands as possible.
  
  Input
  
  The first line contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.
  
  The next 2t lines contain descriptions of the test cases.
  
  In the description of each test case, the first line contains two integers n and m (1 ≤ n, m ≤ 10^6) — the height and width of the field that the robot is located on. The second line of the description is a string s consisting solely of characters 'L', 'R', 'D' and 'U' — the sequence of commands the robot executes. The string has a length from 1 to 10^6 commands.
  
  It is guaranteed that the total length of s over all test cases does not exceed 10^6.
  
  Output
  
  Print t lines, each of which contains the answer to the corresponding test case. The answer to the test case are two integers r (1 ≤ r ≤ n) and c (1 ≤ c ≤ m), separated by a space — the coordinates of the cell (row number and column number) from which the robot should start moving to perform as many commands as possible.
  
  If there are several such cells, you may output any of them.
  
  Example
  
  Input
  
  
  4
  1 1
  L
  1 2
  L
  3 3
  RRDLUU
  4 3
  LUURRDDLLLUU
  
  
  Output
  
  
  1 1
  1 2
  2 1
  3 2
solution: import java.io.*;
  import java.util.*;
  
  public class Main {
      static PrintWriter pw;
      static Scanner sc;
      static long ceildiv(long x, long y) { return (x+y-1) / y; }
      static int mod(long x, int m) { return (int) ((x%m + m) % m); }
      static void put(Map<Integer, Integer> map, Integer p){if(map.containsKey(p)) map.replace(p, map.get(p)+1); else map.put(p, 1); }
      static void rem(Map<Integer, Integer> map, Integer p){ if(map.get(p)==1) map.remove(p); else map.replace(p, map.get(p)-1); }
      static int Int(boolean x){ return x ? 1 : 0; }
      static final int inf=(int)1e9, mod= inf + 7;
      static final long infL=inf*1l*inf;
      static final double eps=1e-9;
      public static long gcd(long x, long y) { return y==0? x: gcd(y, x%y); }
      public static void main(String[] args) throws Exception {
          sc = new Scanner(System.in);
          pw = new PrintWriter(System.out);
          int t = sc.nextInt();
          while (t-- > 0)
              testCase();
          pw.close();
      }
  
      static void testCase() throws Exception{
          int n = sc.nextInt(), m = sc.nextInt();
          String s = sc.next();
          Pair curr = new Pair(0, 0), max = new Pair(0, 0), min = new Pair(0, 0);
          for (int i = 0; i < s.length(); i++) {
              curr = change(curr, s.charAt(i));
              if(Math.abs(curr.x) == m || Math.abs(curr.y) == n){
                  print(combine(max, min), n, m);
                  return;
              }
              Pair prevMax = max.clone();
              Pair prevMin = min.clone();
              max.x = Math.max(max.x, curr.x);
              max.y = Math.max(max.y, curr.y);
              min.x = Math.min(min.x, curr.x);
              min.y = Math.min(min.y, curr.y);
              if(max.x - min.x >= m || max.y - min.y >= n){
                  print(combine(prevMax, prevMin), n, m);
                  return;
              }
          }
          print(combine(max, min), n, m);
      }
  
      static Pair combine(Pair max, Pair min){
          int x = Math.abs(max.x) > Math.abs(min.x) ? max.x : min.x;
          int y = Math.abs(max.y) > Math.abs(min.y) ? max.y : min.y;
          return new Pair(x, y);
      }
  
      static Pair change(Pair p, char change){
          if(change == 'L')
              return new Pair(p.x-1, p.y);
          if(change == 'R')
              return new Pair(p.x+1, p.y);
          if(change == 'D')
              return new Pair(p.x, p.y-1);
          return new Pair(p.x, p.y+1);
      }
  
      static void print(Pair ans, int n, int m){
          int x = ans.x < 0 ? -ans.x : m - ans.x - 1;
          int y = ans.y < 0 ? -ans.y : n - ans.y - 1;
          pw.println((n-y) + " " + (x+1));
      }
  
  
      static void printArr(int[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
  
      static void printArr(long[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
  
      static void printArr(double[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
  
      static void printArr(Integer[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
  
      static void printIter(Iterable list) {
          for (Object o : list)
              pw.print(o + " ");
          pw.println();
      }
  
      static class Scanner {
          StringTokenizer st;
          BufferedReader br;
  
          public Scanner(InputStream s) {
              br = new BufferedReader(new InputStreamReader(s));
          }
  
          public Scanner(FileReader r) {
              br = new BufferedReader(r);
          }
  
          public String next() throws IOException {
              while (st == null || !st.hasMoreTokens())
                  st = new StringTokenizer(br.readLine());
              return st.nextToken();
          }
  
          public int nextInt() throws IOException {
              return Integer.parseInt(next());
          }
  
          public long nextLong() throws IOException {
              return Long.parseLong(next());
          }
  
          public String nextLine() throws IOException {
              return br.readLine();
          }
  
          public double nextDouble() throws IOException {
              return Double.parseDouble(next());
          }
  
          public int[] nextDigits() throws IOException {
              String s = nextLine();
              int[] arr = new int[s.length()];
              for (int i = 0; i < arr.length; i++)
                  arr[i] = s.charAt(i) - '0';
              return arr;
          }
  
          public int[] nextArr(int n) throws IOException {
              int[] arr = new int[n];
              for (int i = 0; i < arr.length; i++)
                  arr[i] = nextInt();
              return arr;
          }
  
          public Integer[] nextsort(int n) throws IOException {
              Integer[] arr = new Integer[n];
              for (int i = 0; i < n; i++)
                  arr[i] = nextInt();
              return arr;
          }
  
          public Pair nextPair() throws IOException {
              return new Pair(nextInt(), nextInt());
          }
  
          public long[] nextLongArr(int n) throws IOException {
              long[] arr = new long[n];
              for (int i = 0; i < n; i++)
                  arr[i] = nextLong();
              return arr;
          }
  
          public Pair[] nextPairArr(int n) throws IOException {
              Pair[] arr = new Pair[n];
              for (int i = 0; i < n; i++)
                  arr[i] = nextPair();
              return arr;
          }
  
          public boolean hasNext() throws IOException {
              return (st != null && st.hasMoreTokens()) || br.ready();
          }
      }
  
      static class Pair implements Comparable<Pair> {
          int x;
          int y;
  
          public Pair(int x, int y) {
              this.x = x;
              this.y = y;
          }
  
          public Pair(Map.Entry<Integer, Integer> a) {
              x = a.getKey();
              y = a.getValue();
          }
  
          public int hashCode() {
              return (int) ((this.x*1l*100003 + this.y) % mod);
          }
  
          public int compareTo(Pair p) {
              if(x != p.x)
                  return x - p.x;
              return y - p.y;
          }
  
          public boolean equals(Object obj) {
              if (obj == null) {
                  return false;
              }
              if (this.getClass() != obj.getClass()) {
                  return false;
              }
              Pair p = (Pair) obj;
              return this.x == p.x && this.y == p.y;
          }
  
          public Pair clone() {
              return new Pair(x, y);
          }
  
          public String toString() {
              return this.x + " " + this.y;
          }
  
          public void subtract(Pair p) {
              x -= p.x;
              y -= p.y;
          }
  
          public void add(Pair p) {
              x += p.x;
              y += p.y;
          }
      }
  }