import java.util.*;
import java.io.*;

public class aaaaaaaaaaaaaaaa {
	boolean[][] visited;
	int bmoves;

	public void run() throws Exception {
		FastReader file = new FastReader();
		int times = file.nextInt();
		for (int asdf = 0; asdf < times; asdf++) {
			int r = file.nextInt(), c = file.nextInt();
			char[][] mat = new char[r][c];
			for (int i = 0; i < r; i++) {
				mat[i] = file.next().toCharArray();
			}
			int gcnt = 0;
			boolean works = true;
			// surround all Bs
			for (int i = 0; i < r; i++) {
				for (int j = 0; j < c; j++) {
					if (mat[i][j] == 'B') {
						if (i + 1 < r && mat[i + 1][j] == '.')
							mat[i + 1][j] = '#';
						else if (i + 1 < r && mat[i + 1][j] == 'G')
							works = false;
						if (i - 1 >= 0 && mat[i - 1][j] == '.')
							mat[i - 1][j] = '#';
						else if (i - 1 >= 0 && mat[i - 1][j] == 'G')
							works = false;
						if (j + 1 < c && mat[i][j + 1] == '.')
							mat[i][j + 1] = '#';
						else if (j + 1 < c && mat[i][j + 1] == 'G')
							works = false;
						if (j - 1 >= 0 && mat[i][j - 1] == '.')
							mat[i][j - 1] = '#';
						else if (j - 1 >= 0 && mat[i][j - 1] == 'G')
							works = false;

					} else if (mat[i][j] == 'G')
						gcnt++;
				}
			}
			// check for each G to see if it works
			if (!works)
				System.out.println("No");
			else {
				if (gcnt == 0)
					works = true;
				else if (mat[r - 1][c - 1] == '#' || mat[r - 1][c - 1] == 'B')
					works = false;
				else {
					int cnt = 0;
					Queue<Integer> x = new LinkedList(), y = new LinkedList();
					visited = new boolean[r][c];
					x.add(r - 1);
					y.add(c - 1);
					while (!x.isEmpty()) {
						int curX = x.poll(), curY = y.poll();
						if (curX >= 0 && curX < r && curY >= 0 && curY < c && !visited[curX][curY]
								&& mat[curX][curY] != '#') {
							if (mat[curX][curY] == 'G')
								cnt++;
							visited[curX][curY] = true;
							x.add(curX + 1);
							y.add(curY);
							x.add(curX - 1);
							y.add(curY);
							x.add(curX);
							y.add(curY + 1);
							x.add(curX);
							y.add(curY - 1);
						}
					}
					if (cnt == gcnt)
						works = true;
					else
						works = false;
				}
				System.out.println(works ? "Yes" : "No");
			}
		}
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

	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;
		}
	}
}