import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class UndergroundSystem {

	public static void main(String args[]) {
		Scanner input = new Scanner(System.in);
		int T = input.nextInt();
		for (int i = 1; i <= T; i++) {
			int n = input.nextInt();
			int m = input.nextInt();
			char[][] c = new char[n + 1][m + 1];
			for (int ii = 0; ii < n; ii++) {
				String s = input.next();
				for (int iii = 0; iii < m; iii++) {
					c[ii][iii] = s.charAt(iii);
				}
			}
			boolean ok = true;
			for (int ii = 0; ii < n; ii++) {
				for (int iii = 0; iii < m; iii++) {
					if (c[ii][iii] == 'B') {
						if (ii > 0) {
							if (c[ii - 1][iii] == 'G') {
								ok = false;
							}
							if (c[ii - 1][iii] == '.') {
								c[ii - 1][iii] = '#';
							}
						}
						if (ii < n - 1) {
							if (c[ii + 1][iii] == 'G') {
								ok = false;
							}
							if (c[ii + 1][iii] == '.') {
								c[ii + 1][iii] = '#';
							}
						}
						if (iii > 0) {
							if (c[ii][iii - 1] == 'G') {
								ok = false;
							}
							if (c[ii][iii - 1] == '.') {
								c[ii][iii - 1] = '#';
							}
						}
						if (iii < m - 1) {
							if (c[ii][iii + 1] == 'G') {
								ok = false;
							}
							if (c[ii][iii + 1] == '.') {
								c[ii][iii + 1] = '#';
							}
						}
					}
				}
			}
			if (!ok) {
				System.out.println("No");
				continue;
			}
			boolean[][] canVisit = new boolean[n + 1][m + 1];
			boolean[][] visited = new boolean[n + 1][m + 1];
			dfs(canVisit, visited, n - 1, m - 1, c, n, m);
			ok = true;
			for (int ii = 0; ii < n; ii++) {
				for (int iii = 0; iii < m; iii++) {
					if (c[ii][iii] == 'G' && !canVisit[ii][iii]) {
						ok = false;
					}
					if (c[ii][iii] == 'B' && canVisit[ii][iii]) {
						ok = false;
					}
				}
			}
			if (!ok) {
				System.out.println("No");
				continue;
			}
			System.out.println("Yes");
		}

	}

	private static void dfs(boolean[][] canVisit, boolean[][] visited, int n, int m, char[][] c, int maxN, int maxM) {
		visited[n][m] = true;
		if (c[n][m] == '#') {
			return;
		}
		canVisit[n][m] = true;
		if (n > 0 && !visited[n - 1][m]) {
			dfs(canVisit, visited, n - 1, m, c, maxN, maxM);
		}
		if (n < maxN - 1 && !visited[n + 1][m]) {
			dfs(canVisit, visited, n + 1, m, c, maxN, maxM);
		}
		if (m > 0 && !visited[n][m - 1]) {
			dfs(canVisit, visited, n, m - 1, c, maxN, maxM);
		}
		if (m < maxM - 1 && !visited[n][m + 1]) {
			dfs(canVisit, visited, n, m + 1, c, maxN, maxM);
		}
	}
}
