import java.io.*;
import java.util.*;


public class D {

    static class Pair<U extends Comparable<U>, V extends Comparable<V>>
            implements Comparable<Pair<U,V>>{

        public final U a;
        public final V b;

        private Pair(U a, V b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;

            Pair<?, ?> pair = (Pair<?, ?>) o;
            if (!a.equals(pair.a))
                return false;
            return b.equals(pair.b);
        }

        @Override
        public int hashCode() {
            return 31 * a.hashCode() + b.hashCode();
        }

        @Override
        public String toString() {
            return "(" + a + ", " + b + ")";
        }

        @Override
        public int compareTo(Pair<U, V> o) {
            if(this.a.equals(o.a)){
                return getV().compareTo(o.getV());
            }
            return getU().compareTo(o.getU());
        }
        private U getU() {
            return a;
        }
        private V getV() {
            return b;
        }
    }

    static BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
    static ArrayList<Integer> arrayList;
    static int count = 0;
    static String[][] matrix;
    static ArrayList<Pair<Integer,Integer>> list;
    public static void main(String[] args) throws IOException {


        int t = Integer.parseInt(inp.readLine());
        while (t-->0){
            ans = true;
            String[] s1 = inp.readLine().split(" ");
            int row = Integer.parseInt(s1[0]);
            int col = Integer.parseInt(s1[1]);

            count = 0;

            matrix = new String[row][col];
            list = new ArrayList<>();

            for(int i=0;i<row;i++){
                s1 = inp.readLine().split("");
                for(int j=0;j<col;j++){
                    matrix[i][j] = s1[j];
                    if(s1[j].equals("B")){
                        list.add(new Pair<>(i,j));
                    }
                    if(s1[j].equals("G")){
                        count++;
                    }
                }
            }


            DFS(matrix,col,row);
//            System.out.println();
//            System.out.println(countGGGGG);
            DFS(row,col);

            //print(matrix);
            if(matrix[row-1][col-1].equals("B")){
                ans = false;
            }

            if(matrix[row-1][col-1].equals("#") && count>0){
                ans = false;
            }

            if(ans && countGGGGG ==count){
                out.write("Yes"+"\n");

            }
            else{
                out.write("No"+"\n");
            }



        }


        out.flush();



    }

    static boolean[][] visited1;
    static int countGGGGG = 0;

    static void DFS(int row,int col){
        countGGGGG = 0;
        visited1 = new boolean[row][col];
        DFSutil(col,row,row-1,col-1);

    }

    static void DFSutil(int col,int row,int i,int j){
        visited[i][j] = true;
        if(matrix[i][j].equals("G")){
            countGGGGG++;
        }

        if(j+1<col && (matrix[i][j+1].equals(".") || matrix[i][j+1].equals("G")) && !visited[i][j+1]){
            DFSutil(col,row,i,j+1);
        }

        if(i+1<row && (matrix[i+1][j].equals(".")|| matrix[i+1][j].equals("G"))&& !visited[i+1][j]){
            DFSutil(col,row,i+1,j);
        }

        if(j-1>=0 && (matrix[i][j-1].equals(".") || matrix[i][j-1].equals("G"))&& !visited[i][j-1]){
            DFSutil(col,row,i,j-1);
        }

        if(i-1>=0 && (matrix[i-1][j].equals(".")|| matrix[i-1][j].equals("G"))&& !visited[i-1][j]){
            DFSutil(col,row,i-1,j);
        }

    }

    static boolean ans = true;
    static boolean[][] visited;// = new boolean[row][col];
    static void DFS(String[][] matrix,int col,int row){
        visited = new boolean[row][col];
        for(int i=0;i<list.size();i++){
            Pair<Integer,Integer> pair = list.get(i);
            if(!visited[pair.a][pair.b]){
                DFSutil(matrix,col,row,pair.a,pair.b);
            }
        }

    }

    static void DFSutil(String[][] matrix,int col,int row,int i,int j){
        visited[i][j] = true;
        //System.out.println(i+" "+j);
        if(j+1<col && matrix[i][j+1].equals("B") && !visited[i][j+1]){
            DFSutil(matrix,col,row,i,j+1);
        }

        if(i+1<row && matrix[i+1][j].equals("B")&& !visited[i+1][j]){
            DFSutil(matrix,col,row,i+1,j);
        }

        if(j-1>=0 && matrix[i][j-1].equals("B")&& !visited[i][j-1]){
            DFSutil(matrix,col,row,i,j-1);
        }

        if(i-1>=0 && matrix[i-1][j].equals("B")&& !visited[i-1][j]){
            DFSutil(matrix,col,row,i-1,j);
        }

        if(j+1<col && matrix[i][j+1].equals("G")){
            ans = false;
        }
        else if(j+1<col && matrix[i][j+1].equals(".")){
            matrix[i][j+1] = "#";
        }
        if(i+1<row && matrix[i+1][j].equals("G")){
            ans = false;
        }
        else if(i+1<row && matrix[i+1][j].equals(".")){
            matrix[i+1][j] = "#";
        }

        if(j-1>-1 && matrix[i][j-1].equals("G")){
            ans = false;
        }
        else if(j-1>-1 && matrix[i][j-1].equals(".")){
            matrix[i][j-1] = "#";
        }

        if(i-1>-1 && matrix[i-1][j].equals("G")){
            ans = false;
        }
        else if(i-1>-1 && matrix[i-1][j].equals(".")){
            matrix[i-1][j] = "#";
        }


    }

    static void solve(int a,int b)throws IOException{
        if(count>10){
            return;
        }
        count++;


        int mid = (a+b)/2;

        out.write("? "+(b-a+1)+"");
        for(int i=a;i<=b;i++){
            out.write(" "+i);
        }
        out.write("\n");
        out.flush();
        int c = Integer.parseInt(inp.readLine());
        if(c!=-1){
            arrayList.add(c);
        }

            if(mid!=a) {
                solve(a, mid);
            }
            if(mid!=b) {
                solve(mid+1, b);
            }



    }


    static void print(int[] array){
        for(int j=0;j<array.length;j++){
            System.out.print(array[j]+" ");
        }
        System.out.println();
    }
    static void print(int[][] array){
        for(int i=0;i< array.length;i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
    static void print(boolean[] array){
        for(int j=0;j<array.length;j++){
            System.out.print(array[j]+" ");
        }
        System.out.println();
    }
    static void print(boolean[][] array){
        for(int i=0;i< array.length;i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
    static void print(long[] array){
        for(int j=0;j<array.length;j++){
            System.out.print(array[j]+" ");
        }
        System.out.println();
    }
    static void print(long[][] array){
        for(int i=0;i< array.length;i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
    static void print(String[] array){
        for(int j=0;j<array.length;j++){
            System.out.print(array[j]+" ");
        }
        System.out.println();
    }
    static void print(String[][] array){
        for(int i=0;i< array.length;i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
}