Problem: Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:

  * Empty — '.' 
  * Wall — '#' 
  * Good person — 'G' 
  * Bad person — 'B' 



The only escape from the maze is at cell (n, m).

A person can move to a cell only if it shares a side with their current cell and does not contain a wall. Vivek wants to block some of the empty cells by replacing them with walls in such a way, that all the good people are able to escape, while none of the bad people are able to. A cell that initially contains 'G' or 'B' cannot be blocked and can be travelled through.

Help him determine if there exists a way to replace some (zero or more) empty cells with walls to satisfy the above conditions.

It is guaranteed that the cell (n,m) is empty. Vivek can also block this cell.

Input

The first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers n, m (1 ≤ n, m ≤ 50) — the number of rows and columns in the maze.

Each of the next n lines contain m characters. They describe the layout of the maze. If a character on a line equals '.', the corresponding cell is empty. If it equals '#', the cell has a wall. 'G' corresponds to a good person and 'B' corresponds to a bad person.

Output

For each test case, print "Yes" if there exists a way to replace some empty cells with walls to satisfy the given conditions. Otherwise print "No"

You may print every letter in any case (upper or lower).

Example

Input


6
1 1
.
1 2
G.
2 2
#B
G.
2 3
G.#
B#.
3 3
#B.
#..
GG.
2 2
#B
B.


Output


Yes
Yes
No
No
Yes
Yes

Note

For the first and second test cases, all conditions are already satisfied.

For the third test case, there is only one empty cell (2,2), and if it is replaced with a wall then the good person at (1,2) will not be able to escape.

For the fourth test case, the good person at (1,1) cannot escape.

For the fifth test case, Vivek can block the cells (2,3) and (2,2).

For the last test case, Vivek can block the destination cell (2, 2).

Solution (in JAVA):

Solution:

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Round648 {

	static int X[] = { -1, 0, 0, 1 };
	static int Y[] = { 0, -1, 1, 0 };

	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[64]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}

	static class Node {
		int val;
		int type;
		int ind;

		public Node(int val, int type, int ind) {
			this.val = val;
			this.type = type;
			this.ind = ind;
		}
	}

	public static long[] initArray(int n, Reader scan) throws IOException {

		long arr[] = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = scan.nextLong();
		}

		return arr;
	}

	public static long sum(long arr[]) {

		long sum = 0;
		for (long i : arr) {
			sum += (long) i;
		}

		return sum;
	}

	public static long max(long arr[]) {

		long max = Long.MIN_VALUE;

		for (long i : arr) {
			max = Math.max(i, max);
		}

		return max;
	}

	public static long min(long arr[]) {
		long min = Long.MAX_VALUE;

		for (long i : arr) {
			min = Math.min(i, min);
		}

		return min;
	}

	public static List<Integer>[] initAdjacency(int n, int e, Reader scan, boolean type) throws IOException {

		List<Integer> adj[] = new ArrayList[n + 1];

		for (int i = 0; i < e; i++) {
			int u = scan.nextInt();
			int v = scan.nextInt();

			if (adj[u] == null)
				adj[u] = new ArrayList<>();
			if (type && adj[v] == null)
				adj[v] = new ArrayList<>();

			adj[u].add(v);

			if (type)
				adj[v].add(u);

		}

		return adj;
	}

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		while (t-- > 0) {
			int n = scan.nextInt();
			int m = scan.nextInt();

			int arr[][] = new int[n][m];

			for (int i = 0; i < n; i++) {
				String s = scan.next();
				for (int j = 0; j < m; j++) {
					if (s.charAt(j) == '.') {
						arr[i][j] = 0;
					}
					if (s.charAt(j) == '#') {
						arr[i][j] = 1;
					}

					if (s.charAt(j) == 'G') {
						arr[i][j] = 2;
					}
					if (s.charAt(j) == 'B') {
						arr[i][j] = 3;
					}
				}
			}

			D(arr, n, m);
		}

	}

	public static void A(int n, int m, long arr[][]) {

		int rC = 0;
		int cC = 0;

		int rows[] = new int[n];
		int cols[] = new int[m];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (arr[i][j] == 1) {
					rows[i]++;
					cols[j]++;
				}
			}
		}

		for (int i : rows) {
			if (i == 0) {
				rC++;
			}
		}

		for (int j : cols) {
			if (j == 0) {
				cC++;
			}
		}

		int turn = 0;

		turn = Math.min(rC, cC) % 2;

		if (turn == 0) {
			System.out.println("Vivek");
		} else {
			System.out.println("Ashish");
		}

	}

	public static void B(List<Node> arr) {

		boolean allSame = true;
		boolean isInc = true;

		int last = 0;
		int lastType = arr.get(0).type;
		for (int i = 0; i < arr.size(); i++) {
			if (arr.get(i).type != lastType) {
				System.out.println("Yes");
				return;
			}

			if (arr.get(i).val < last) {
				isInc = false;
			}

			last = arr.get(i).val;
		}

		if (isInc) {
			System.out.println("Yes");
		}

		else {
			System.out.println("No");
		}

	}

	public static int C(long arr1[], long arr2[], int n) {

		int ind[] = new int[n + 1];

		for (int i = 0; i < n; i++) {
			ind[(int) arr2[i]] = i;
		}

		int dist[] = new int[n];

		for (int i = 0; i < n; i++) {

			long val = arr1[i];
			int idx = ind[(int) val];
			if (idx < i) {
				dist[i] = i - idx;
			} else {
				dist[i] = n - idx + i;
			}
		}

		int maxVals[] = new int[n + 1];
		for (int i : dist) {
			maxVals[i]++;
		}

		int ans = 1;

		for (int i : maxVals) {
			ans = Math.max(i, ans);
		}

		return ans;

	}

	public static void D(int arr[][], int n, int m) {

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (arr[i][j] == 3) {

					for (int k = 0; k < 4; k++) {
						int x = i + X[k];
						int y = j + Y[k];

						if (x >= 0 && x < n && y >= 0 && y < m) {
							if (arr[x][y] == 2) {
								System.out.println("No");
								return;
							} else if (arr[x][y] == 0) {
								arr[x][y] = 1;

							}
						}
					}
				}
			}
		}

		int r[][] = new int[n][m];

		dfs(n - 1, m - 1, r, arr, n, m);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (arr[i][j] == 3 && r[i][j] == 1) {

					System.out.println("No");
					return;

				}

				if (arr[i][j] == 2 && r[i][j] == 0) {

					System.out.println("No");
					return;

				}
			}
		}

		System.out.println("Yes");

	}

	public static void dfs(int i, int j, int reachable[][], int arr[][], int n, int m) {

		if(arr[i][j]==1) {
			reachable[i][j]=0;
			return;
		}
		
		reachable[i][j] = 1;

		for (int k = 0; k < 4; k++) {
			int x = i + X[k];
			int y = j + Y[k];

			if (x >= 0 && x < n && y >= 0 && y < m && arr[x][y] != 1 && reachable[x][y] == 0) {
				dfs(x, y, reachable, arr, n, m);
			}
		}

	}
}