//package CodeforcesJava;

import java.io.*;
import java.util.*;

public class Main {

    public void solve(InputProvider in, PrintWriter out) throws IOException {
        int testCount = in.nextInt();
        for (int test = 0; test < testCount; test++) {
            int rowCount = in.nextInt();
            int columnCount = in.nextInt();
            int[][] map = new int[rowCount][columnCount];
            Set<Position> badPositions = new HashSet<>();
            Set<Position> goodPositions = new HashSet<>();
            for (int row = 0; row < map.length; row++) {
                String rowDescription = in.nextLine();
                for (int column = 0; column < map[row].length; column++) {
                    map[row][column] = rowDescription.charAt(column);
                    if (map[row][column] == 'B') {
                        badPositions.add(new Position(row, column));
                    }
                    if (map[row][column] == 'G') {
                        goodPositions.add(new Position(row, column));
                    }
                }
            }
            boolean can;
            if (goodPositions.isEmpty()) {
                can = true;
            } else {
                boolean badBlocked = true;
                for (Iterator<Position> iterator = badPositions.iterator(); iterator.hasNext() && badBlocked; ) {
                    Position badPosition = iterator.next();
                    badBlocked = tryBlock(map, badPosition);
                }
                if (!badBlocked) {
                    can = false;
                } else {
                    can = findWay(map, goodPositions);
                }
            }
            out.print(can ? "Yes\n" : "No\n");
        }
    }

    private static class Position {

        private final int row;
        private final int column;

        private Position(int row, int column) {
            this.row = row;
            this.column = column;
        }

        @Override
        public int hashCode() {
            return Objects.hash(row, column);
        }

        @Override
        public boolean equals(Object obj) {
            return (obj instanceof Position) && (((Position) obj).row == row) && (((Position) obj).column == column);
        }

    }

    private static boolean tryBlock(int[][] map, Position position) {
        boolean canBlock = true;
        for (int row = Math.max(0, position.row - 1);
             row <= Math.min(position.row + 1, map.length - 1) && canBlock; row++) {
            for (int column = Math.max(0, position.column - 1);
                 column <= Math.min(position.column + 1, map[row].length - 1) && canBlock; column++) {
                canBlock = map[row][column] != 'G';
                map[row][column] = '#';
            }
        }
        return canBlock;
    }

    private static boolean findWay(int[][] map, Set<Position> targetPositions) {
        Position start = new Position(map.length - 1, map[0].length - 1);
        Queue<Position> availablePositions = new LinkedList<>();
        availablePositions.add(start);
        while (!availablePositions.isEmpty() && !targetPositions.isEmpty()) {
            Position position = availablePositions.poll();
            for (int row = Math.max(0, position.row - 1);
                 row <= Math.min(position.row + 1, map.length - 1); row++) {
                for (int column = Math.max(0, position.column - 1);
                     column <= Math.min(position.column + 1, map[row].length - 1); column++) {
                    Position here = new Position(row, column);
                    if (map[row][column] != '#') {
                        availablePositions.add(here);
                    }
                    targetPositions.remove(here);
                }
            }
        }
        return targetPositions.isEmpty();
    }

    public static void main(String[] args) throws Exception {
        try (InputProvider input = new InputProvider(System.in);
             PrintWriter output = new PrintWriter(System.out)) {
            new Main().solve(input, output);
        }
    }

    public static class InputProvider implements AutoCloseable {

        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputProvider(Reader reader) {
            this.reader = new BufferedReader(reader);
        }

        public InputProvider(InputStream input) {
            reader = new BufferedReader(new InputStreamReader(input));
        }

        public String next() throws IOException {
            if (Objects.isNull(tokenizer) || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }

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

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

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

        public String nextLine() throws IOException {
            return reader.readLine();
        }

        @Override
        public void close() throws Exception {
            reader.close();
        }

    }

}