import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.function.BiPredicate;
import java.util.List;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Asgar Javadov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            char[][] maze = in.readCharMatrix(n, m);

            GridConditions grid = new GridConditions(n, m);

            IntPair escape = IntPair.newPair(n - 1, m - 1);

            BiPredicate<Integer, Integer> isEmptyOrGood = new TaskD.IsEmptyOrGoodPredicate(maze);

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++)
                    if (maze[i][j] == 'B') {
                        List<IntPair> emptyOrGood = grid.neighbours(IntPair.newPair(i, j), isEmptyOrGood);
                        for (IntPair cell : emptyOrGood) {
                            if (isGood(maze, cell)) {
                                out.No();
                                return;
                            }
                            maze[cell.first][cell.second] = '#';
                        }
                    }
            }


            boolean[][] seen = new boolean[n][m];
            BiPredicate<Integer, Integer> isAvailable = new TaskD.IsAvailable(maze, seen);

//        Queue<IntPair> que = new LinkedList<>();
//        if (maze[n - 1][m - 1] != '#')
//            que.offer(IntPair.newPair(n - 1, m - 1));
//        while (!que.isEmpty()) {
//            IntPair cur = que.poll();
//            seen[cur.first][cur.second] = true;
//
//            que.addAll(grid.neighbours(cur, isAvailable));
//        }

            if (maze[n - 1][m - 1] != '#')
                dfs(escape, seen, grid, isAvailable);

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++)
                    if (maze[i][j] == 'G' && !seen[i][j]) {
                        out.No();
                        return;
                    }
            }
            out.Yes();
        }

        private void dfs(IntPair node, boolean[][] seen, GridConditions grid, BiPredicate<Integer, Integer> isAvailable) {
            seen[node.first][node.second] = true;
            grid.neighbours(node, isAvailable).forEach(neighbor -> dfs(neighbor, seen, grid, isAvailable));
        }

        private boolean isGood(char[][] maze, IntPair pair) {
            return maze[pair.first][pair.second] == 'G';
        }

        static class IsEmptyOrGoodPredicate implements BiPredicate<Integer, Integer> {
            private char[][] maze;

            public IsEmptyOrGoodPredicate(char[][] maze) {
                this.maze = maze;
            }

            public boolean test(Integer i, Integer j) {
                return maze[i][j] == '.' || maze[i][j] == 'G';
            }

        }

        static class IsAvailable implements BiPredicate<Integer, Integer> {
            private char[][] maze;
            private boolean[][] seen;

            public IsAvailable(char[][] maze, boolean[][] seen) {
                this.maze = maze;
                this.seen = seen;
            }

            public boolean test(Integer i, Integer j) {
                return !seen[i][j] && maze[i][j] != '#';
            }

        }

    }

    static class GridConditions {
        public static int[] rowDelta = {-1, 0, 1, 0};
        public static int[] columnDelta = {0, 1, 0, -1};
        private int rows;
        private int cols;
        private List<IntPair> tempList;
        private IntPair[] tempPair;

        public GridConditions(int rows, int cols) {
            this.rows = rows;
            this.cols = cols;

            this.tempList = new LinkedList<>();
            this.tempPair = new IntPair[4];
//        IntPair[] pairs = Stream.generate(IntPair::newPair).limit(4).toArray(IntPair[]::new);
            for (int i = 0; i < tempPair.length; ++i)
                tempPair[i] = IntPair.newPair();
        }

        public boolean withinBorders(int row, int col) {
            return 0 <= row && row < rows
                    && 0 <= col && col < cols;
        }

        public List<IntPair> neighbours(IntPair cell, BiPredicate<Integer, Integer> available) {
            LinkedList<IntPair> tempList = new LinkedList<>();
            int i = cell.first;
            int j = cell.second;
            for (int k = 0; k < rowDelta.length; k++) {
                int row = i + rowDelta[k];
                int col = j + columnDelta[k];

                if (withinBorders(row, col) && available.test(row, col)) {
                    tempList.add(IntPair.newPair(row, col));
                }
            }

            return tempList;
        }

    }

    static class IntPair implements Comparable<IntPair> {
        public int first;
        public int second;

        public IntPair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        public int compareTo(IntPair o) {
            if (first != o.first)
                return Integer.compare(first, o.first);
            return Integer.compare(second, o.second);
        }

        public String toString() {
            return first + " " + second;
        }

        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof IntPair)) return false;
            IntPair intPair = (IntPair) o;
            return first == intPair.first &&
                    second == intPair.second;
        }

        public int hashCode() {
            return (31 * first + second);
        }

        public IntPair clone() {
            return newPair(first, second);
        }

        public static IntPair newPair() {
            return new IntPair(0, 0);
        }

        public static IntPair newPair(int first, int second) {
            return new IntPair(first, second);
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void Yes() {
            println("Yes");
        }

        public void No() {
            println("No");
        }

        public void close() {
            super.close();
        }

    }

    static class InputReader extends BufferedReader {
        StringTokenizer tokenizer;

        public InputReader(InputStream inputStream) {
            super(new InputStreamReader(inputStream), 32768);
        }

        public InputReader(String filename) {
            super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(readLine());
                } catch (IOException e) {
                    throw new RuntimeException();
                }
            }
            return tokenizer.nextToken();
        }

        public Integer nextInt() {
            return Integer.valueOf(next());
        }

        public char[][] readCharMatrix(int n, int m) {
            char[][] result = new char[n][];
            for (int i = 0; i < n; i++) {
                result[i] = next().toCharArray();
            }
            return result;
        }

    }
}

