import java.io.*;
import java.math.*;
import java.util.*;
public class R648Q4 {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int T = input.nextInt();
		for (int i = 1; i <= T; i++) {
			int rows = input.nextInt();
			int cols = input.nextInt();
			boolean bad = false;
			char[][] grid = new char[rows][cols];
			for (int r = 0; r < rows; r++) {
				grid[r]=input.next().toCharArray();
			}
			for (int r = 0; r < rows; r++) {
				for (int c = 0; c < cols; c++){
					if (grid[r][c]=='B') { //Confining bad people by blocking all cardinal directions
						if (r>0) {
							if (grid[r-1][c]=='G') bad=true;
							else grid[r-1][c]='#';
						}
						if (r<rows-1) {
							if (grid[r+1][c]=='G') bad=true;
							else grid[r+1][c]='#';
						}
						if (c>0) {
							if (grid[r][c-1]=='G') bad=true;
							else grid[r][c-1]='#';
						}
						if (c<cols-1) {
							if (grid[r][c+1]=='G') bad=true;
							else grid[r][c+1]='#';
						}
					}
					if (bad) break;
				}
				if (bad) break;
			}
			/*for (int r = 0; r < rows; r++) {
				for (int c = 0; c < cols; c++) {
					System.out.print(grid[r][c]);
				}
				System.out.print("\n");
			}*/
			if (!bad) { //Actual DFS needed if test case is not trivial
				for (int r = 0; r < rows; r++) {
					for (int c = 0; c < cols; c++) {
						if (grid[r][c]=='G') {
							boolean[][] vis = new boolean[rows][cols];
							int[] start = {r,c};
							int[] end = {rows-1,cols-1};
							if (!DFS(start,end,vis,grid)) {
								bad=true;
								break;
							} 
						}
					}
					if (bad) break;
				}
			}
			System.out.println(bad?"No":"Yes");
		}
	}
	public static boolean DFS(int[] start, int[] end, boolean[][] vis, char[][] grid) {
		Stack<int[]> cur = new Stack<int[]>();
		boolean[][] curvis = new boolean[grid.length][grid[0].length];
		cur.push(start);
		while (!cur.isEmpty()) {
			int[] arr = cur.peek();
			int r = arr[0];
			int c = arr[1];
			boolean added=false;
			if (r==end[0]&&c==end[1]) return true;
			if (r>0&&grid[r-1][c]!='#'&&!vis[r-1][c]) {
				int[] tuple = {r-1,c};
				if (!curvis[tuple[0]][tuple[1]]) {
					cur.push(tuple);
					added=true;
					curvis[tuple[0]][tuple[1]]=true;
				}
			}
			else if (r<vis.length-1&&grid[r+1][c]!='#'&&!vis[r+1][c]) {
				int[] tuple = {r+1,c};
				if (!curvis[tuple[0]][tuple[1]]) {
					cur.push(tuple);
					added=true;
					curvis[tuple[0]][tuple[1]]=true;
				}
			}
			else if (c>0&&grid[r][c-1]!='#'&&!vis[r][c-1]) {
				int[] tuple = {r,c-1};
				if (!curvis[tuple[0]][tuple[1]]) {
					cur.push(tuple);
					added=true;
					curvis[tuple[0]][tuple[1]]=true;
				}
			}
			else if (c<vis[0].length-1&&grid[r][c+1]!='#'&&!vis[r][c+1]) {
				int[] tuple = {r,c+1};
				if (!curvis[tuple[0]][tuple[1]]) {
					cur.push(tuple);
					added=true;
					curvis[tuple[0]][tuple[1]]=true;
				}
			}
			if (!added) {
				int[] tuple = cur.pop();
				vis[tuple[0]][tuple[1]]=true;
			}
		}
		return false;
	}
}
