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){
            String[] s1 = inp.readLine().split(" ");
            int row = Integer.parseInt(s1[0]);
            int col = Integer.parseInt(s1[1]);

            int 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();
//
            //print(matrix);

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

            //System.out.println(list);

            if(ans){

                Set<Pair<Integer,Integer>>[][] dp = new Set[row][col];

                for(int i=0;i<row;i++) {

                    for (int j = 0; j < col; j++) {

                    dp[i][j] = new HashSet<>();
                    }

                }
                for(int i=0;i<row;i++){

                    for(int j=0;j<col;j++){
                        if(matrix[i][j].equals("G")){
                            if(i+1<row && (matrix[i+1][j].equals(".") || matrix[i+1][j].equals("G"))){
                                Iterator<Pair<Integer,Integer>> iterator = dp[i][j].iterator();
                                while (iterator.hasNext()){
                                    dp[i+1][j].add(iterator.next());
                                }
                                dp[i+1][j].add(new Pair<>(i,j));

                            }

                            if(j+1<col && ( matrix[i][j+1].equals(".")|| matrix[i][j+1].equals("G"))){
                                Iterator<Pair<Integer,Integer>> iterator = dp[i][j].iterator();
                                while (iterator.hasNext()){
                                    dp[i][j+1].add(iterator.next());
                                }
                                dp[i][j+1].add(new Pair<>(i,j));
                            }

                        }
                        else if(matrix[i][j].equals(".")){
                            if(i+1<row && (matrix[i+1][j].equals(".") || matrix[i+1][j].equals("G"))){
                                Iterator<Pair<Integer,Integer>> iterator = dp[i][j].iterator();
                                while (iterator.hasNext()){
                                    dp[i+1][j].add(iterator.next());
                                }
                            }

                            if(j+1<col && ( matrix[i][j+1].equals(".")|| matrix[i][j+1].equals("G"))){
                                Iterator<Pair<Integer,Integer>> iterator = dp[i][j].iterator();
                                while (iterator.hasNext()){
                                    dp[i][j+1].add(iterator.next());
                                }
                            }
                        }

                    }

                }

//                for(int i=0;i<row;i++) {
//
//                    for (int j = 0; j < col; j++) {
//
//                        System.out.print(dp[i][j]+" ");
//                    }
//                    System.out.println();
//
//                }

                if(dp[row-1][col-1].size()==count){
                    out.write("Yes"+"\n");
                }
                else{
                    out.write("No"+"\n");
                }

                //System.out.println(dp[row-1][col-1]);

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



        }
        list.clear();
        ans = true;

        out.flush();



    }
    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")){
            DFSutil(matrix,col,row,i,j+1);
        }

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

        if(j+1<col && matrix[i][j+1].equals("W")){
            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("W")){
            ans = false;
        }
        else if(i+1<row && 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();
        }
    }
}