import java.io.*;
import java.util.*;

public class prop {
	static Scanner sc;

	static int n, m;
	static char c[][];
	static boolean  memo[][];
	static boolean visited[][];
	static boolean dp(int i,int j) {
		if(i==n-1 && j==m-1)
			return c[i][j]=='.';
		if(!valid(i,j))
			return false;
		if(visited[i][j])
			return memo[i][j];
		visited[i][j]=true;
		return memo[i][j]= dp(i+1,j)||dp(i-1,j)||dp(i,j+1)||dp(i,j-1);
	}
	
	static boolean valid(int i, int j) {
		return (i >= 0 && i < n && j >= 0 && j < m);
	}

	public static void main(String[] args) throws IOException {
		sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int t = sc.nextInt();
		while (t-- > 0) {
			n = sc.nextInt();
			m = sc.nextInt();
			c = new char[n][m];
			for (int i = 0; i < c.length; i++) {
				c[i] = sc.nextLine().toCharArray();
			}
			boolean f = c[n - 1][m - 1] != 'B';
			for (int i = 0; i < c.length; i++) {
				for (int j = 0; j < m; j++) {
					if (c[i][j] == 'B') {
						if (valid(i + 1, j)) {
							if (c[i + 1][j] == 'G')
								f = false;
							if (c[i + 1][j] != 'B')
								c[i + 1][j] = '#';
						}
						if (valid(i - 1, j)) {
							if (c[i - 1][j] == 'G')
								f = false;
							if (c[i - 1][j] != 'B')
								c[i - 1][j] = '#';
						}
						if (valid(i, j + 1)) {
							if (c[i][j + 1] == 'G')
								f = false;
							if (c[i][j + 1] != 'B')
								c[i][j + 1] = '#';
						}
						if (valid(i, j - 1)) {
							if (c[i][j - 1] == 'G')
								f = false;
							if (c[i][j - 1] != 'B')
								c[i][j - 1] = '#';
						}
					}
				}
			}
			memo=new boolean[n][m];
			visited=new boolean[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if(c[i][j]=='G') {
						f&=dp(i,j);
					}
				}
			}
			pw.println(f ? "Yes" : "No");
		}
		pw.close();
	}

	static class pair implements Comparable<pair> {
		int x, y;

		pair(int s, int d) {
			x = s;
			y = d;
		}

		@Override
		public int compareTo(pair p) {
			return x - p.x;
		}

		@Override
		public String toString() {
			return x + " " + y;
		}
	}

	//////////////////////////////////////////////////////////////////////////////////////////////////
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}