import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Map.Entry;


import java.util.Random;
import java.util.TreeSet;

public final class CF_648_D2_D
{


	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void logWln(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputFlush(Object o){try {out.write(""+ o+"\n");out.flush();} catch (Exception e) {}}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}


	static void logBin(int[] tm) {for (int x:tm) logWln(bin(8,x)+" ");log("");}

	static String bin(int L,int x) {
		String s=Integer.toBinaryString(x);
		while (s.length()<L) s="0"+s;
		return s;
	}

	static long powerMod(long b,long e,long m){
		long x=1;
		while (e>0) {
			if (e%2==1)
				x=(b*x)%m;
			b=(b*b)%m;
			e=e/2;
		}
		return x; 
	}


	static class Composite implements Comparable<Composite>{

		int val;
		int idx;


		public int compareTo(Composite X) {
			if (val!=X.val)
				return val-X.val;
			return idx-X.idx;
		}


		public Composite(int val, int idx) {
			this.val = val;
			this.idx = idx;
		}







	}

	// Global vars
	static BufferedWriter out;
	static InputReader reader;

	static int[][] dd={{-1,0},{0,1},{1,0},{0,-1}};



	static long mod=1000000007;

	static void process() throws Exception {

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader = new InputReader(System.in);

		int MX=51;
		int[][] stack=new int[MX*MX][2];
		int[][] visited=new int[MX][MX];
		int time=0;
		int T=reader.readInt();
		for (int t=0;t<T;t++) {
			time++;
			int n=reader.readInt();
			int m=reader.readInt();
			char[][] map=new char[n][];
			for (int i=0;i<n;i++) {
				String s=reader.readString();
				map[i]=s.toCharArray();
			}
			boolean ok=true;
			int good=0;
			loop:for (int i=0;i<n;i++)
				for (int j=0;j<m;j++) {
					if (map[i][j]=='B') {
						for (int[] tm:dd) {
							int uu=i+tm[0];
							int vv=j+tm[1];
							if (uu>=0 && uu<n && vv>=0 && vv<m) {
								char c=map[uu][vv];
								if (c=='G') {
									ok=false;
									break loop;
								}
								if (c=='.') {
									map[uu][vv]='#';
								}
							}
						}
					} else if (map[i][j]=='G')
						good++;
				}
			String ans="No";
			if (ok) {
				// do flood fill from zero
				if (map[n-1][m-1]=='.') {
					int st=0;
					stack[st][0]=n-1;
					stack[st][1]=m-1;
					visited[n-1][m-1]=time;
					st++;
					while (st>0) {
						int u=stack[st-1][0];
						int v=stack[st-1][1];
						st--;
						for (int[] tm:dd) {
							int uu=u+tm[0];
							int vv=v+tm[1];
							if (uu>=0 && uu<n && vv>=0 && vv<m && visited[uu][vv]<time) {
								char c=map[uu][vv];
								if (c!='#') {
									stack[st][0]=uu;
									stack[st][1]=vv;
									st++;
									visited[uu][vv]=time;
									if (c=='G')
										good--;
								}
								
							}
						}
						
					}
					
					
				}
				
				if (good==0)
					ans="Yes";
				
			}
			output(ans);

		}

		try {
			out.close();
		} catch (Exception Ex) {
		}

	}





	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final String readString(int L) throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder(L);
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}