
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 + 2][m + 2];
            b = new boolean[n + 2][m + 2];
            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;
                        }
                    }
                }
            }
            b = new boolean[n + 2][m + 2];
            if (a[n][m] != 0 && a[n][m] != 3) {
                g(n, m, n, m, a, b);
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (a[i][j] == 2) {
                        System.out.println("No");
                        continue outwhile;
                    }
                }
            }
            System.out.println("Yes");
        }
    }

    private static void 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;
            b[i][j] = true;
            a[i][j] = 2-1;
            int ii, jj;
            ii = 0;
            jj = -1;
            if (!b[i + ii][j + jj]) {
                b[i + ii][j + jj] = true;
                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;
                }
            }
            jj = 1;
            if (!b[i + ii][j + jj]) {
                b[i + ii][j + jj] = true;
                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
                        break;
                }
            }

            //*******************
            jj = 0;
            ii = -1;
            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
                        break;
                }
            }
            ii = 1;
            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
                        break;
                }
            }
        }
    }

    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;

            int ii, jj;
            ii = 0;
            jj = -1;
            if (!b[i + ii][j + jj]) {
                b[i + ii][j + jj] = true;
                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));

                }
            }
            jj = 1;
            if (!b[i + ii][j + jj]) {
                b[i + ii][j + jj] = true;
                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));

                }
            }

            //////////////
            jj = 0;
            ii = -1;
            if (!b[i + ii][j + jj]) {
                b[i + ii][j + jj] = true;
                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));

                }
            }
            ii = 1;
            if (!b[i + ii][j + jj]) {
                b[i + ii][j + jj] = true;
                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;
    }

}
