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.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.*;
  
  
  public class Main {
  
  	static long mod = 1_000_000_007;
  
  	public static void main(String[] args) {
  
  		FastScanner f = new FastScanner();
  		PrintWriter p = new PrintWriter(System.out);
  		int t=f.nextInt();
  		while(t-->0) {
  			int n=f.nextInt();
  			int m=f.nextInt();
  			char c[]=f.next().toCharArray();
  			int l=0;int r=0;int u=0;int d=0;
  			int x=0;int y=0;
  			for(int i=0;i<c.length;i++) {
  				if(c[i]=='R') {
  					r=Math.max(r, ++y);
  				}else if(c[i]=='L') {
  					l=Math.min(l, --y);
  				}else if(c[i]=='U') {
  					u=Math.min(u, --x);
  				}else {
  					d=Math.max(d, ++x);
  				}
  				
  				if(r-l>=m) {
  					if(y==l) l++;
  					break;
  				}
  				
  				if(d-u>=n) {
  					if(x==u) u++;
  					break;
  				}
  			}
  			int resx=1-u;
  			int resy=1-l;
  			p.println(resx+" "+resy);
  		}
  		p.close();
  
  	}
  	
  	
  
  	
  	
  	
  	
  
  	
  
  //-----------------------------------------------------------------------------------------------------------------------------------------------------------------
  
  	static int offx[] = { -1, -1, -1, 0, 1, 1, 1, 0 };
  	static int offy[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
  
  	static class FastScanner {
  		BufferedReader br;
  		StringTokenizer st;
  
  		public FastScanner() {
  			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;
  		}
  	}
  
  	static long add(long x, long y) {
  		x += y;
  		if (x >= mod)
  			return (x % mod);
  		return x;
  	}
  
  	static long sub(long x, long y) {
  		x -= y;
  		if (x < 0)
  			return (x + mod);
  		return x;
  	}
  
  	static long mul(long x, long y) {
  		return (x * y) % mod;
  	}
  
  	static long bin_pow(long x, long p) {
  		if (p == 0)
  			return 1;
  		if ((p & 1) != 0)
  			return mul(x, bin_pow(x, p - 1));
  		return bin_pow(mul(x, x), p / 2);
  	}
  
  	static long rev(long x) {
  		return bin_pow(x, mod - 2);
  	}
  
  	static long div(long x, long y) {
  		return mul(x, rev(y));
  	}
  
  	// will work till array size of 65537---fastest sorting time
  	static long[] radixSort(long[] f) {
  		return radixSort(f, f.length);
  	}
  
  	static long[] radixSort(long[] f, int n) {
  		long[] to = new long[n];
  		{
  			int[] b = new int[65537];
  			for (int i = 0; i < n; i++)
  				b[1 + (int) (f[i] & 0xffff)]++;
  			for (int i = 1; i <= 65536; i++)
  				b[i] += b[i - 1];
  			for (int i = 0; i < n; i++)
  				to[b[(int) (f[i] & 0xffff)]++] = f[i];
  			long[] d = f;
  			f = to;
  			to = d;
  		}
  		{
  			int[] b = new int[65537];
  			for (int i = 0; i < n; i++)
  				b[1 + (int) (f[i] >>> 16 & 0xffff)]++;
  			for (int i = 1; i <= 65536; i++)
  				b[i] += b[i - 1];
  			for (int i = 0; i < n; i++)
  				to[b[(int) (f[i] >>> 16 & 0xffff)]++] = f[i];
  			long[] d = f;
  			f = to;
  			to = d;
  		}
  		{
  			int[] b = new int[65537];
  			for (int i = 0; i < n; i++)
  				b[1 + (int) (f[i] >>> 32 & 0xffff)]++;
  			for (int i = 1; i <= 65536; i++)
  				b[i] += b[i - 1];
  			for (int i = 0; i < n; i++)
  				to[b[(int) (f[i] >>> 32 & 0xffff)]++] = f[i];
  			long[] d = f;
  			f = to;
  			to = d;
  		}
  		{
  			int[] b = new int[65537];
  			for (int i = 0; i < n; i++)
  				b[1 + (int) (f[i] >>> 48 & 0xffff)]++;
  			for (int i = 1; i <= 65536; i++)
  				b[i] += b[i - 1];
  			for (int i = 0; i < n; i++)
  				to[b[(int) (f[i] >>> 48 & 0xffff)]++] = f[i];
  			long[] d = f;
  			f = to;
  			to = d;
  		}
  		return f;
  	}
  
  	// Function to sort an array using quick sort algorithm.
  	static void quickSort(long arr[], int low, int high) {
  		if (low < high) {
  			int p = partition(arr, low, high);
  			quickSort(arr, low, p - 1);
  			quickSort(arr, p + 1, high);
  		}
  	}
  
  	static int partition(long arr[], int low, int high) {
  		long pivot = arr[high];
  		int i = low - 1;
  		for (int j = low; j < high; j++) {
  			if (arr[j] < pivot) {
  				i++;
  				long temp = arr[i];
  				arr[i] = arr[j];
  				arr[j] = temp;
  			}
  		}
  		long temp = arr[i + 1];
  		arr[i + 1] = arr[high];
  		arr[high] = temp;
  
  		return i + 1;
  	}
  
  	/// Ceils
  	static long ceil(long x, long m) {
  		long res = x / m;
  		if (x % m != 0) {
  			res++;
  		}
  		return res;
  	}
  
  	// ------------------------------------------------------------------------------------------------
  	// makes the prefix sum array
  	static long[] prefixSum(long arr[], int n) {
  		long psum[] = new long[n];
  		psum[0] = arr[0];
  		for (int i = 1; i < n; i++) {
  			psum[i] = psum[i - 1] + arr[i];
  		}
  		return psum;
  	}
  	// ------------------------------------------------------------------------------------------------
  
  	// makes the suffix sum array
  	static long[] suffixSum(long arr[], int n) {
  		long ssum[] = new long[n];
  		ssum[n - 1] = arr[n - 1];
  		for (int i = n - 2; i >= 0; i--) {
  			ssum[i] = ssum[i + 1] + arr[i];
  		}
  		return ssum;
  	}
  
  //------------------------------------------------------------------------------------------
  	// BINARY EXPONENTIATION OF A NUMBER MODULO M FASTER METHOD WITHOUT RECURSIVE
  	// OVERHEADS
  //	static long m = (long) (1e9 + 7);
  
  	static long binPower(long a, long n, long m) {
  		if (n == 0)
  			return 1;
  		long res = 1;
  		while (n > 0) {
  			if ((n & 1) != 0) {
  				res *= a;
  			}
  			a *= a;
  			n >>= 1;
  		}
  		return res;
  	}
  
  //-------------------------------------------------------------------------------------------
  
  	// gcd
  	static long gcd(long a, long b) {
  		return b == 0 ? a : gcd(b, a % b);
  	}
  
  //------------------------------------------------------------------------------------------
  
  	// lcm
  	static long lcm(long a, long b) {
  		return a / gcd(a, b) * b;
  	}
  
  	// ------------------------------------------------------------------------------------------
  	// BRIAN KERNINGHAM TO CHECK NUMBER OF SET BITS
  	// O(LOGn)
  	static int setBits(int n) {
  		int count = 0;
  		while (n > 0) {
  			n = n & (n - 1);
  			count++;
  		}
  		return count;
  	}
  //------------------------------------------------------------------------------------------
  
  	// ------------------------------------------------------------------------------------------
  	// 0 based indexing
  	static boolean KthBitSet(int n, int k) {
  		int mask = 1;
  		mask = mask <<= k;
  		if ((mask & n) != 0)
  			return true;
  		else
  			return false;
  	}
  
  //------------------------------------------------------------------------------------------
  
  	// EXTENDED EUCLIDEAN THEOREM
  	// TO REPRESENT GCD IN TERMS OF A AND B
  	// gcd(a,b) = a.x + b.y where x and y are integers
  
  	static long x = -1;
  	static long y = -1;
  
  	static long gcdxy(long a, long b) {
  		if (b == 0) {
  			x = 1;
  			y = 0;
  			return a;
  		} else {
  			long d = gcdxy(b, a % b);
  			long x1 = y;
  			long y1 = x - (a / b) * y;
  			x = x1;
  			y = y1;
  
  			return d;
  		}
  	}
  
  //-------------------------------------------------------------------------------------------------
  }
  