import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collection;
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.util.Queue;
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);

            List<IntPair> goods = getPeople(n, m, maze, 'G');

            if (goods.isEmpty()) {
                out.Yes();
                return;
            }

            int[][] path = new int[n][m];

            Queue<Triplet> que = new LinkedList<>();
            que.offer(Triplet.of(n - 1, m - 1, 0));
            GridConditions grid = new GridConditions(n, m);
            boolean[][] seen = new boolean[n][m];

            while (!que.isEmpty()) {
                Triplet cur = que.poll();
                seen[cur.first][cur.second] = true;
                path[cur.first][cur.second] = cur.third;

                List<IntPair> neighbours = grid.neighbours(cur.first, cur.second, (i, j) -> !seen[i][j] && maze[i][j] != '#');

                for (IntPair cell : neighbours) {
                    que.offer(Triplet.of(cell, cur.third + 1));
                }
            }

            for (IntPair good : goods) {
                if (path[good.first][good.second] == 0) {
                    out.No();
                    return;
                }
            }

            List<IntPair> bads = getPeople(n, m, maze, 'B');

            for (IntPair bad : bads) {
                List<IntPair> emptyOrGood = grid.neighbours(bad, (i, j) -> maze[i][j] != '#' && maze[i][j] != 'B');
                List<IntPair> empty = grid.neighbours(bad, (i, j) -> maze[i][j] != '#' && maze[i][j] != 'B' && maze[i][j] != 'G');

                if (emptyOrGood.size() != empty.size()) {
                    out.No();
                    return;
                }

                for (IntPair cell : empty) {
                    if (cell.equals(IntPair.newPair(n - 1, m - 1))) {
                        out.No();
                        return;
                    }
                    maze[cell.first][cell.second] = '#';
                }
            }

            if (checkMaze(n, m, maze)) {
                out.Yes();
            } else {
                out.No();
            }
        }

        private boolean checkMaze(int n, int m, char[][] maze) {
            int[][] path = new int[n][m];

            Queue<Triplet> que = new LinkedList<>();
            que.offer(Triplet.of(n - 1, m - 1, 0));
            GridConditions grid = new GridConditions(n, m);
            boolean[][] seen = new boolean[n][m];

            while (!que.isEmpty()) {
                Triplet cur = que.poll();
                seen[cur.first][cur.second] = true;
                path[cur.first][cur.second] = cur.third;

                List<IntPair> neighbours = grid.neighbours(cur.first, cur.second, (i, j) -> !seen[i][j] && maze[i][j] != '#');

                for (IntPair cell : neighbours) {
                    que.offer(Triplet.of(cell, cur.third + 1));
                }
            }

            List<IntPair> goods = getPeople(n, m, maze, 'G');
            for (IntPair good : goods) {
                if (path[good.first][good.second] == 0) {
                    return false;
                }
            }

            return true;
        }

        private List<IntPair> getPeople(int n, int m, char[][] maze, char type) {
            List<IntPair> cells = new LinkedList<>();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (maze[i][j] == type) {
                        cells.add(IntPair.newPair(i, j));
                    }
                }
            }
            return cells;
        }

    }

    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) {
            return neighbours(cell.first, cell.second, available);
        }

        public List<IntPair> neighbours(int i, int j, BiPredicate<Integer, Integer> available) {
            this.tempList.clear();
            int index = 0;
            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)) {
                    tempPair[index].first = row;
                    tempPair[index].second = col;

                    tempList.add(tempPair[index++]);
                }
            }

            return tempList;
        }

    }

    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;
        }

    }

    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 Triplet extends IntPair {
        public int third;

        public Triplet(int first, int second, int third) {
            super(first, second);
            this.third = third;
        }

        public static Triplet of(int first, int second, int value) {
            return new Triplet(first, second, value);
        }

        public static Triplet of(IntPair pair, int value) {
            return new Triplet(pair.first, pair.second, value);
        }

        public int compareTo(IntPair o) {
            int compareAsPair = super.compareTo(o);
            if (compareAsPair != 0)
                return compareAsPair;

            return Integer.compare(third, ((Triplet) o).third);
        }

        public String toString() {
            return "{first=" + first +
                    ", second=" + second +
                    ", third=" + third +
                    '}';
        }

    }

    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();
        }

    }
}

