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

	private static FastReader fr = new FastReader();
	private static Helper helper = new Helper();
	private static StringBuilder result = new StringBuilder();
 
	public static void main(String[] args) {
		Task solver = new Task();
		solver.solve();
	}
 
	static class Task {
		private static StringBuilder result = new StringBuilder();
		
		private boolean isWithin(char[][] arr, int i, int j){
			return i >= 1 && i <= arr.length-2 && j>= 1 && j <= arr[0].length-2 && arr[i][j] != '#';
		}
		
		private boolean isPossible(char[][] arr, int i, int j, boolean[][] isVisited){
			if(!isWithin(arr, i, j)) return false;
			if(i == arr.length-2 && j == arr[0].length-2){
				return true;
			}
			if(isVisited[i][j]) return false;
			
			isVisited[i][j] = true;
			boolean ans = isPossible(arr, i, j+1, isVisited) || isPossible(arr, i, j-1, isVisited)
							|| isPossible(arr, i-1, j, isVisited) || isPossible(arr, i+1, j, isVisited);
			isVisited[i][j] = false; 
			
			return ans;
		}
		
		public void solve() {
		    int nt = fr.ni();
			while(nt-- > 0){
				int r = fr.ni();
				int c = fr.ni();
				char[][] arr = new char[r+2][c+2];
				for(char[] subArr : arr) Arrays.fill(subArr, '.');
				for(int i=1; i<r+1; i++){
					String str = fr.next();
					for(int j=1; j<c+1; j++){
						arr[i][j] = str.charAt(j-1);
					}
				}
				for(int i=1; i<r+1; i++){
					for(int j=1; j<c+1; j++){
						if(arr[i][j] == '#') continue;
						if(arr[i][j] == 'B'){
							if(arr[i][j-1] == '.') arr[i][j-1] = '#';
							if(arr[i-1][j] == '.') arr[i-1][j] = '#';
							if(arr[i][j+1] == '.') arr[i][j+1] = '#';
							if(arr[i+1][j] == '.') arr[i+1][j] = '#';
						}
					}
				}
				boolean[][] isVisited;
				boolean ans = true;
				for(int i=1; i<r+1; i++){
					for(int j=1; j<c+1; j++){
						if(arr[i][j] == 'G'){
							isVisited = new boolean[r+2][c+2];
							ans = isPossible(arr, i, j, isVisited);
							if(!ans) break;
						}
					}
					if(!ans) break;
				}
				if(ans){
					result.append("Yes\n");
				}
				else result.append("No\n");
			}
			System.out.println(result.toString());
		}
	}
 
	static class Helper{
		public long[] tiArr(int n, int si){
			long[] arr = new long[n];
			for(int i=si; i<n; i++) arr[i] = fr.nl();
			return arr;
		}
	}
 
	static class FastReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		private static PrintWriter pw;
 
		public FastReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
			pw = new PrintWriter(System.out);
			tokenizer = null;
		}
 
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
 
		public int ni() {
			return Integer.parseInt(next());
		}
 
		public long nl() {
			return Long.parseLong(next());
		}
 
		public String rl() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
 
		public void print(String str) {
			pw.print(str);
			pw.flush();
		}
	}
}