import java.util.*;
import java.io.*;
public class SolveTheMaze {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int t = Integer.parseInt(in.nextLine());
        for (int i = 0; i < t; i++) {
            String[] temp = in.nextLine().split(" ");
            int n = Integer.parseInt(temp[0]);
            int m = Integer.parseInt(temp[1]);
            boolean[][] checkPath = new boolean[n][m];
            String[][] maze = new String[n][m];
            int bad = 0;
            ArrayList<String> goodPair = new ArrayList<>();
            for(int a = 0; a < n; a++)
            {
                String temp1 = in.nextLine();
                for(int b = 0; b < m; b++)
                {
                    maze[a][b] = temp1.substring(b,b+1);
                }
            }
            for(int a = 0; a < n; a++)
            {
                for(int b = 0; b < m; b++)
                {
                    if(maze[a][b].equals("G"))
                    {
                        goodPair.add(a + " " + b);
                    }
                    else if(maze[a][b].equals("B"))
                    {
                        change(maze, n, m, a, b, checkPath);
                        checkPath[a][b] = true;
                        bad++;
                    }
                }
            }
            if(goodPair.size() == 0 && bad > 0)
            {
                out.println("Yes");
            }
            else
            {
                boolean works = true;
                ArrayList<String> goodSquare = new ArrayList<String>();
                dfs(checkPath, n, m, goodSquare, maze);
                for(int k = 0; k < goodPair.size(); k++)
                {
                    if(!goodSquare.contains(goodPair.get(k)))
                    {
                        works = false;
                        break;
                    }
                }
                if(!works)
                {
                    out.println("No");
                }
                else {
                    out.println("Yes");
                }
            }
        }
        out.close();
    }
    public static void change(String[][] maze, int n, int m, int a, int b, boolean[][] checkPath)
    {
        if(a - 1 >= 0 && maze[a - 1][b].equals("."))
        {
            checkPath[a - 1][b] = true;
        }
        if(b - 1 >= 0 && maze[a][b - 1].equals("."))
        {
            checkPath[a][b - 1] = true;
        }
        if(a + 1 < n && maze[a + 1][b].equals("."))
        {
            checkPath[a + 1][b] = true;
        }
        if(b + 1 < m && maze[a][b + 1].equals("."))
        {
            checkPath[a][b + 1] = true;
        }
    }
    public static void dfs(boolean[][] checkPath, int n, int m, ArrayList<String> goodPath, String[][] maze)
    {
        Stack<String> stack = new Stack<>();
        stack.push((n - 1) + " " + (m - 1));
        while(!stack.empty())
        {
            String x = stack.pop();
            int row = Integer.parseInt(x.split(" ")[0]);
            int col = Integer.parseInt(x.split(" ")[1]);
            if(row >= n || col >= m || row < 0 || col < 0 || checkPath[row][col] || maze[row][col].equals("#"))
            {
                continue;
            }
            goodPath.add(x);
            stack.push(row + " " + (col - 1));
            stack.push((row + 1) + " " + col);
            stack.push((row - 1) + " " + col);
            stack.push(row + " " + (col + 1));
            checkPath[row][col] = true;
        }
    }
}