import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    static ArrayList<Integer> rowqueue = new ArrayList<Integer>();
    static ArrayList<Integer> colqueue = new ArrayList<Integer>();
    static boolean possible = true;

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        for (int i = 0; i < t; i++)
        {
            solution(scan);
        }
    }

    static void solution(Scanner scan)
    {
        int n = scan.nextInt();
        int m = scan.nextInt();
        ArrayList<Integer[]> goodguys = new ArrayList<Integer[]>();
        ArrayList<Integer[]> badguys = new ArrayList<Integer[]>();
        String[][] grid = new String[n][m];
        int[][] matrix = new int[n][m];
        possible = true;
        for (int i = 0; i < n; i++)
        {
            String row = scan.next();
            for (int j = 0; j < m; j++)
            {
                grid[i][j] = String.valueOf(row.charAt(j));
                if (grid[i][j].equals("G"))
                {
                    Integer[] goodguy = {i, j};
                    goodguys.add(goodguy);
                }
                else if (grid[i][j].equals("B"))
                {
                    Integer[] badguy = {i, j};
                    badguys.add(badguy);
                }
            }
        }
        for (int i = 0; i < badguys.size(); i++)
        {
            if (!possible)
            {
                System.out.println("No");
                return;
            }
            blockbfs(grid, badguys.get(i), n, m);
        }
        for (int i = 0; i < goodguys.size(); i++)
        {
            if (!possible)
            {
                System.out.println("No");
                return;
            }
            bfs(grid, goodguys.get(i), n, m);
        }
        if (!possible) System.out.println("No");
        else System.out.println("Yes");

    }
    static void blockbfs(String[][] grid, Integer[] guy, int n, int m)
    {
        int[][] matrix = new int[n][m];
        int[] rowvec = {1, -1, 0, 0};
        int[] colvec = {0, 0, 1, -1};
        int r = guy[0];
        int c = guy[1];
            for (int i = 0; i < 4; i++)
            {
                int rr = r + rowvec[i];
                int cc = c + colvec[i];
                if (rr < 0 || cc < 0) continue;
                if (rr >= n || cc >= m) continue;
                if (matrix[rr][cc] == 1) continue;
                if (grid[rr][cc].equals("G")) {
                    possible = false;
                    //System.out.println("Neighbor with good guy");
                    return;
                };
                if (grid[rr][cc].equals(".")) {
                    grid[rr][cc] = "#";
                    continue;
                }
            }

    }

    static void bfs(String[][] grid, Integer[] guy, int n, int m)
    {
        int[][] matrix = new int[n][m];
        int rr;
        int cc;
        int[] rowvec = {1, -1, 0, 0};
        int[] colvec = {0, 0, 1, -1};
        rowqueue.add(guy[0]);
        colqueue.add(guy[1]);
        while (!rowqueue.isEmpty())
        {
            int r = rowqueue.remove(0);
            int c = colqueue.remove(0);
            for (int i = 0; i < 4; i++)
            {
                rr = r + rowvec[i];
                cc = c + colvec[i];

                if (rr < 0 || cc < 0) continue;
                if (rr >= n || cc >= m) continue;
                if (matrix[rr][cc] == 1) continue;
                if (grid[rr][cc].equals("#")) continue;

                matrix[rr][cc] = 1;
                rowqueue.add(rr);
                colqueue.add(cc);
            }
        }
        rowqueue.clear();
        colqueue.clear();
        if (grid[n-1][m-1].equals("#"))
        {
            possible = false;
            //System.out.println("good guy didn't reach");
            return;
        }
        return;
    }





}