Problem: Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:

  * Empty — '.' 
  * Wall — '#' 
  * Good person — 'G' 
  * Bad person — 'B' 



The only escape from the maze is at cell (n, m).

A person can move to a cell only if it shares a side with their current cell and does not contain a wall. Vivek wants to block some of the empty cells by replacing them with walls in such a way, that all the good people are able to escape, while none of the bad people are able to. A cell that initially contains 'G' or 'B' cannot be blocked and can be travelled through.

Help him determine if there exists a way to replace some (zero or more) empty cells with walls to satisfy the above conditions.

It is guaranteed that the cell (n,m) is empty. Vivek can also block this cell.

Input

The first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers n, m (1 ≤ n, m ≤ 50) — the number of rows and columns in the maze.

Each of the next n lines contain m characters. They describe the layout of the maze. If a character on a line equals '.', the corresponding cell is empty. If it equals '#', the cell has a wall. 'G' corresponds to a good person and 'B' corresponds to a bad person.

Output

For each test case, print "Yes" if there exists a way to replace some empty cells with walls to satisfy the given conditions. Otherwise print "No"

You may print every letter in any case (upper or lower).

Example

Input


6
1 1
.
1 2
G.
2 2
#B
G.
2 3
G.#
B#.
3 3
#B.
#..
GG.
2 2
#B
B.


Output


Yes
Yes
No
No
Yes
Yes

Note

For the first and second test cases, all conditions are already satisfied.

For the third test case, there is only one empty cell (2,2), and if it is replaced with a wall then the good person at (1,2) will not be able to escape.

For the fourth test case, the good person at (1,1) cannot escape.

For the fifth test case, Vivek can block the cells (2,3) and (2,2).

For the last test case, Vivek can block the destination cell (2, 2).

Solution (in JAVA):

Solution:
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), (i1, j1) -> maze[i1][j1] == '.' || maze[i1][j1] == 'G');
                        for (IntPair cell : emptyOrGood) {
                            if (isGood(maze, cell)) {
                                out.No();
                                return;
                            }
                            maze[cell.first][cell.second] = '#';
                        }
                    }
            }


            boolean[][] seen = new boolean[n][m];
            if (maze[n - 1][m - 1] != '#')
                dfs(escape, seen, grid, (i, j) -> !seen[i][j] && maze[i][j] != '#');

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

    }
}