import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Round648D {
	
	public static int[] dx = {0, 0, -1, 1};
	public static int[] dy = {-1, 1, 0, 0};
	
	public static LinkedList<Integer>[] adj;
	public static int[] visited;
	
	public static void dfs(int curr, int number) {
		visited[curr] = number;
		for(Integer x : adj[curr]) {
			if(visited[x] == 0) {
				dfs(x, number);
			}
		}
	}
	
	public static boolean Answer(int n, int m, boolean[][] good) {
		int number = 1;
		visited = new int[n * m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				int my_val = i * m + j;
				if(visited[my_val] == 0) {
					dfs(my_val, number++);
				}
			}
		}
		boolean ok = true;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				if(good[i][j]) {
					ok &= visited[i * m + j] == visited[(n - 1) * m + m - 1];
				}
			}
		}
		return ok;
	}

	public static void solve() {
		int t = s.nextInt();
		o: while(t-- >  0) {
			int n = s.nextInt();
			int m = s.nextInt();
			String[] mat = new String[n];
			ArrayList<Pair> bads = new ArrayList<>();
			ArrayList<Pair> goods = new ArrayList<>();
			boolean[][] blocks = new boolean[n][m];
			boolean[][] good = new boolean[n][m];
			for(int i = 0; i < n; i++) {
				mat[i] = s.next();
				for(int j = 0; j < m; j++) {
					if(mat[i].charAt(j) == '#') {
						blocks[i][j] = false;
					}else if(mat[i].charAt(j) == 'B') {
						bads.add(new Pair(i, j));
						blocks[i][j] = true;
					}else if(mat[i].charAt(j) == 'G') {
						goods.add(new Pair(i, j));
						good[i][j] = true;
						blocks[i][j] = true;
					}else {
						blocks[i][j] = true;
					}
				}
			}
			for(Pair x : bads) {
				int i = x.x;
				int j = x.y;
				if(i - 1 >= 0) {
					if(good[i - 1][j]) {
						out.println("No");
						continue o;
					}
					blocks[i - 1][j] = false;
				}
				if(i + 1 < n) {
					if(good[i + 1][j]) {
						out.println("No");
						continue o;
					}
					blocks[i + 1][j] = false;
				}
				if(j - 1 >= 0) {
					if(good[i][j - 1]) {
						out.println("No");
						continue o;
					}
					blocks[i][j - 1] = false;
				}
				if(j + 1 < m) {
					if(good[i][j + 1]) {
						out.println("No");
						continue o;
					}
					blocks[i][j + 1] = false;
				}
			}
			adj = new LinkedList[n * m];
			for(int i = 0; i < n * m; i++) {
				adj[i] = new LinkedList<Integer>();
			}
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < m; j++) {
					if(blocks[i][j]) continue;
					if(i + 1 < n && blocks[i + 1][j]) {
						int my_val = i * m + j;
						int next = my_val + m;
						adj[my_val].add(next);
						adj[next].add(my_val);
					}
					if(j + 1 < m && blocks[i][j + 1]) {
						int my_val = i * m + j;
						int next = my_val + 1;
						adj[my_val].add(next);
						adj[next].add(my_val);
					}
				}
			}
			if(Answer(n, m, good)) {
				out.println("Yes");
			}else {
				out.println("No");
			}
		}
	}
	
	public static void flood_fill(boolean[][] blocked, int n, int m, int x, int y, boolean[][] reach) {
		if(x < 0 || y < 0 || x >= n || y >= m) {
			return;
		}
		if(!blocked[x][y]) {
			return;
		}
		if(reach[x][y]) {
			return;
		}
		reach[x][y] = true;
		for(int i = 0; i < 4; i++) {
			flood_fill(blocked, n, m, x + dx[i], y + dy[i], reach);
		}
	}
	
	public static class Pair {
		int x, y;
		
		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}
 
	public static FastReader s;
	public static PrintWriter out;
 
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.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 e) {
				e.printStackTrace();
			}
			return str;
		}
	}
 
	
	
}
