import java.util.ArrayDeque;
import java.util.Scanner;

public class cf1365_Div2_D {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int tc = in.nextInt();
		for ( ; tc > 0; tc--) {
			int n = in.nextInt();
			int m = in.nextInt();
			char[][] grid = new char[n][m];
			
			int[] dx = {0,0,1,-1};
			int[] dy = {1,-1,0,0};
			int whites = 0;
			
			
			for (int i = 0; i < n; i++) {
				grid[i] = in.next().toCharArray();
			}
			
			
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (grid[i][j] == 'B') {
						for (int k = 0; k < 4; k++) {
							int x = dx[k] + i;
							int y = dy[k] + j;
							if (x < n && x >= 0 && y < m && y >= 0 && grid[x][y] == '.') {
								grid[x][y] = '#';
							}
						}
					}
					else if (grid[i][j] == 'G')
						whites++;
				}
			}
			
			ArrayDeque<Integer[]> q = new ArrayDeque<Integer[]>();
			boolean[][] visited = new boolean[n][m];
			if (grid[n - 1][m - 1] != '#') {
				q.add(new Integer[] {n - 1, m - 1});
				visited[n - 1][m - 1] = true;
			}
			int c = 0;
			boolean flag = true;
			while (!q.isEmpty() && flag) {
				Integer[] arr = q.poll();
				int x1 = arr[0];
				int y1 = arr[1];
				if (grid[x1][y1] == 'G')
					c++;
				else if (grid[x1][y1] == 'B'){
					flag = false;
					break;
				}
				for (int i = 0; i < 4; i++) {
					int x = dx[i] + x1;
					int y = dy[i] + y1;
					if (x < n && x >= 0 && y < m && y >= 0 && grid[x][y] != '#' && !visited[x][y]) {
						visited[x][y] = true;
						q.add(new Integer[] {x,y});
					}
						
				}
			}
			
			if (!flag)
				System.out.println("No");
			else if (whites != c)
				System.out.println("No");
			else
				System.out.println("Yes");

		}
	}
}
