import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {

    public static int[] di = new int[] {1, -1, 0, 0};
    public static int[] dj = new int[] {0, 0, 1, -1};

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        for (int i=0; i<t; i++) {
            StringTokenizer st = new StringTokenizer(br.readLine());
            int n = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken());
            char[][] grid = new char[n][m];
            ArrayList<int[]> bad = new ArrayList<>();
            ArrayList<int[]> good = new ArrayList<>();
            for (int j=0; j<n; j++) {
                String line = br.readLine();
                for (int k=0; k<m; k++) {
                    grid[j][k] = line.charAt(k);
                    if (grid[j][k]=='B') {
                        bad.add(new int[] {j, k});
                    } else if (grid[j][k]=='G') {
                        good.add(new int[] {j, k});
                    }
                }
            }
            if (good.size()==0) {
                System.out.println("Yes");
                continue;
            }
            boolean done = false;
            for (int j=0; j<bad.size(); j++) {
                for (int k=0; k<4; k++) {
                    int newX = bad.get(j)[0] + di[k];
                    int newY = bad.get(j)[1] + dj[k];
                    if (newX>=0 && newX<n && newY>=0 && newY<m) {
                        if (grid[newX][newY]=='G') {
                            System.out.println("No");
                            done = true;
                            break;
                        } else if (grid[newX][newY]=='.') {
                            grid[newX][newY] = '#';
                        }
                    }
                }
                if (done) {
                    break;
                }
            }
            if (done) {
                continue;
            }
            int[] start = new int[] {n-1, m-1};
            Queue<int[]> q = new LinkedList<>();
            q.add(start);
            boolean[][] marked = new boolean[n][m];
            while (q.size()!=0) {
                int[] top = q.peek(); q.remove();
                if (top[0]==n-1 && top[1]==m-1) {
                    break;
                }
                if (marked[top[0]][top[1]]) {
                    continue;
                }
                marked[top[0]][top[1]] = true;
                for (int k=0; k<4; k++) {
                    int newX = top[0] + di[k];
                    int newY = top[1] + dj[k];
                    if (newX>=0 && newX<n && newY>=0 && newY<m && grid[newX][newY]!='#') {
                        q.add(new int[] {newX, newY});
                    }
                }
            }
            boolean found = true;
            for (int j=0; j<good.size(); j++) {
                if (!marked[good.get(j)[0]][good.get(j)[1]]) {
                    found = false;
                    break;
                }
            }
            if (found) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}
