import java.math.BigDecimal;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int[] dx = {1, 0, -1, 0};
    int[] dy = {0, 1, 0, -1};
    int t = sc.nextInt();


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        outer:
        for (int i=0; i<t; i++) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            char[][] arr = new char[h][w];
            for (int j=0; j<h; j++) arr[j] = sc.next().toCharArray();

            for (int a=0; a<h; a++) {
                for (int b=0; b<w; b++) {
                    if (arr[a][b] == 'B') {
                        for (int c=0; c<4; c++) {
                            int na = a + dx[c];
                            int nb = b + dy[c];
                            if (na<0 || h<=na || nb<0 || w<=nb) continue;
                            if (arr[na][nb] =='G') {
                                System.out.println("No");
                                continue outer;
                            }
                            arr[na][nb] = '#';
                        }
                    }
                }
            }

            boolean[][] flag = new boolean[h][w];

            boolean gFlag = false;
            for (int a=0; a<h; a++) {
                for (int b=0; b<w; b++) {
                    if (arr[a][b] == 'G') {
                        gFlag = true;
                        Queue<Pair> queue = new ArrayDeque<>();
                        queue.add(new Pair(a, b));
                        flag[a][b] = true;
                        while (!queue.isEmpty()) {
                            Pair pair = queue.peek();
                            flag[pair.a][pair.b] = true;
                            for (int k=0; k<4; k++) {
                                int na = pair.a + dx[k];
                                int nb = pair.b + dy[k];
                                if (na<0 || h<=na || nb<0 || w<=nb) continue;
                                if (arr[na][nb] == '#') continue;
                                if (flag[na][nb]) continue ;
                                queue.add(new Pair(na, nb));
                            }
                            queue.poll();
                        }
                    }
                }
            }

            if (!gFlag) {
                System.out.println("Yes");
                continue outer;
            }

            if (flag[h-1][w-1]) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }


        }

    }

    class Pair{
        int a;
        int b;
        public Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
    }

}
