import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;



public class Main {
	public static class FastReader {
			BufferedReader br;
			StringTokenizer root;
			
	 
			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
	 
			String next() {
				while (root == null || !root.hasMoreTokens()) {
					try {
						root = new StringTokenizer(br.readLine());
					} catch (Exception addd) {
						addd.printStackTrace();
					}
				}
				return root.nextToken();
			}
	 
			int nextInt() {
				return Integer.parseInt(next());
			}
	 
			double nextDouble() {
				return Double.parseDouble(next());
			}
	 
			long nextLong() {
				return Long.parseLong(next());
			}
	 
			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception addd) {
					addd.printStackTrace();
				}
				return str;
			}
		}
	 
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static FastReader sc = new FastReader();
 
	static long mod = (long) (1e9+7),MAX=(long)(1e6+10);
	static List<Integer>[] edges;
    static char[] s,t;
    
    static int[] dx = {0,0,-1,1};
    static int[] dy = {-1,1,0,0};
    static Boolean[][] path;
    
	public static void main(String[] args) throws IOException{

		int t = sc.nextInt();
		while(t-->0) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			char[][] s = new char[n][];
			for(int i=0;i<n;++i) s[i] = sc.next().toCharArray();
			boolean block = true;
			for(int i=0;i<n && block;++i) {
				for(int j=0;j<m && block;++j) {
					if(s[i][j] == 'B') {
						for(int k=0;k<4;++k) {
							int x = i+dx[k];
							int y = j+dy[k];
							if(x>=0 && y>=0 && x < n && y < m && s[x][y] != 'B') {
								if(s[x][y] == 'G') block = false;
								s[x][y] = '#';
							}
						}
					}
				}
			}
			
				if(block) {
					path = new Boolean[n][m];
					boolean[][] vis = new boolean[n][m];
					boolean all = true;
					for(int i=0;i<n && all;++i) {
						for(int j=0;j<m && all;++j) {
							if(s[i][j] == 'G') {
								all&=dfs(i,j,s,n,m,vis);
							//	System.out.println(all+" "+i+","+j);
							}
						}
					}
					if(all) out.println("Yes");
					else out.println("No");
					
				}else out.println("No");
			}
			
		
		
		out.close();
	}

	private static boolean dfs(int i, int j, char[][] s,int n,int m, boolean[][] vis) {
		//System.out.println(i+" "+j);
		if(i == n-1 && j == m-1) return true;
		if(path[i][j]!=null && path[i][j]) return true;
		boolean go = false;
		vis[i][j] = true;
		for(int k=0;k<4;++k) {
			int x = i+dx[k];
			int y = j+dy[k];
			if(x>=0 && y>=0 && x < n && y < m && !vis[x][y]) {
				if(s[x][y] == '#') continue;
				go|=dfs(x,y,s,n,m,vis);
			}
		}
		return path[i][j] = go;
	}
	 
}
			