
import java.util.*;

public class Test {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n, m, t, t2, max;
        t = in.nextInt();
        int[][] a;
        String s;
        boolean[][] b;
        boolean bb;
        
        outwhile : while (t-- > 0) {
            n = in.nextInt();
            m = in.nextInt();
            a = new int[n + 10][m + 10];
            b = new boolean[n + 10][m + 10];
            for (int i = 1; i <= n; i++) {
                s = in.next();
                for (int j = 1; j <= m; j++) {
                    switch (s.charAt(j-1)) {
                        case '#':
                            a[i][j] = 0;
                            break;
                        case '.':
                            a[i][j] = 1;
                            break;
                        case 'G':
                            a[i][j] = 2;
                            break;
                        case 'B':
                            a[i][j] = 3;
                            break;
                    }
                }
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (!b[i][j] && a[i][j] == 3) {
                        bb = f(i, j, n, m, a, b);
                        if (bb) {
                            System.out.println("No");
                            continue outwhile;
                        }
                    }
                }
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (a[i][j] == 2) {
                        b = new boolean[n + 10][m + 10];
                        bb = g(i, j, n, m, a, b);
                        if (!bb) {
                            System.out.println("No");
                            continue outwhile;
                        }
                    }
                }
            }
            System.out.println("Yes");
        }
    }
    
    
    private static boolean g(int i, int j, int n, int m, int[][] a, boolean[][] b) {
        Queue<P> q = new LinkedList<>();
        q.add(new P(i, j));
        while (!q.isEmpty()) {
            P p = q.poll();
            i = p.i;
            j = p.j;
            if (i==n && j==m) {
                return true;
            }
            b[i][j] = true;
            for (int ii = -1; ii <= 1; ii++) {
                for (int jj = -1; jj <= 1; jj++) {
                    if (!b[i + ii][j + jj]) {
                        switch (a[i + ii][j + jj]) {
                            case 0: // divar
                                break;
                            case 1: // khali
                                q.add(new P(i + ii, j + jj));
                                break;
                            case 2: // G
                                q.add(new P(i + ii, j + jj));
                                break;
                            case 3: // B
                                return false;
                        }
                    }
                }
            }
        }
        return false;
    }

    private static boolean f(int i, int j, int n, int m, int[][] a, boolean[][] b) {
        Queue<P> q = new LinkedList<>();
        q.add(new P(i, j));
        while (!q.isEmpty()) {
            P p = q.poll();
            i = p.i;
            j = p.j;
            b[i][j] = true;
            for (int ii = -1; ii <= 1; ii++) {
                for (int jj = -1; jj <= 1; jj++) {
                    if (!b[i + ii][j + jj]) {
                        switch (a[i + ii][j + jj]) {
                            case 0:
                                break;
                            case 1:
                                a[i + ii][j + jj] = 0;
                                break;
                            case 2:
                                return true;
                            case 3:
                                q.add(new P(i + ii, j + jj));

                        }
                    }
                }
            }
        }
        return false;
    }

}

class P {

    int i, j;

    public P(int i, int j) {
        this.i = i;
        this.j = j;
    }

}
