import javax.print.DocFlavor;
import javax.print.attribute.HashAttributeSet;
import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import java.util.*;
import java.lang.*;
import java.io.*;

public class Codechef {
    static class Pair {
        int x;
        int y;
        Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
    static int[][] directions = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
    public static void main(String[] args) throws java.lang.Exception {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new FastReader();
        int test = sc.nextInt();
        for (int t = 0; t < test; t++) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            char[][] arr = new char[n][m];
            for (int i = 0; i < n; i++) {
                arr[i] = sc.next().toCharArray();
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (arr[i][j] == 'B') {
                        for (int[] dir : directions) {
                            int x = dir[0] + i;
                            int y = dir[1] + j;
                            if (valid(x, y, n, m) && arr[x][y] == '.') {
                                arr[x][y] = '#';
                            }
                        }
                    }
                }
            }
            Queue<Pair> queue = new LinkedList<>();
            boolean[][] visited = new boolean[n][m];
            if (arr[n - 1][m - 1] == '.'){
                queue.add(new Pair(n - 1, m - 1));
                visited[n - 1][m - 1] = true;
            }
            while (!queue.isEmpty()) {
                Pair curr = queue.poll();
                for (int[] dir : directions) {
                    int x = dir[0] + curr.x;
                    int y = dir[1] + curr.y;
                    if (valid(x, y, n, m) && !visited[x][y] && arr[x][y] != '#') {
                        queue.add(new Pair(x, y));
                        visited[x][y] = true;
                    }
                }
            }
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (arr[i][j] == 'G' && !visited[i][j]) {
                        ok = false;
                        break;
                    }
                    if (arr[i][j] == 'B' && visited[i][j]) {
                        ok = false;
                        break;
                    }
                }
            }
            if (ok) {
                out.println("Yes");
            }else {
                out.println("No");
            }
        }
        out.close();
    }

    private static boolean valid(int x, int y, int n, int m) {
        if (x >= 0 && x < n && y >= 0 && y < m) {
            return true;
        }
        return false;
    }

    public static FastReader sc;
    public static PrintWriter out;
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}