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.*;
import java.util.Arrays;

public class D2 { // TLE case 10

    static int[] dr = {1, 0, -1, 0};
    static int[] dc = {0, 1, 0, -1};
    static int[][] grid = new int[52][52]; //0: grid; 1: close; 2: end

    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
            int testCnt = Integer.parseInt(br.readLine());
            Arrays.fill(grid[0], 1);
            for (int i = 0; i < testCnt; i++) {
                String[] line = br.readLine().split(" ");
                int rowCnt = Integer.parseInt(line[0]);
                int colCnt = Integer.parseInt(line[1]);
                //create boundaries:
                for (int j = 1; j <= rowCnt; j++) {
                    Arrays.fill(grid[j], 0);
                    grid[j][0] = 1;
                    grid[j][colCnt + 1] = 1;
                }
                Arrays.fill(grid[rowCnt + 1], 1);
                //scan in:
                int gCnt = 0;
                for (int j = 0; j < rowCnt; j++) {
                    String curRow = br.readLine();
                    for (int k = 0; k < colCnt; k++) {
                        char cur = curRow.charAt(k);
                        if (cur == '#') grid[j + 1][k + 1] = 1;
                        else if (cur == 'G') {
                            if (grid[j + 1][k + 1] == 0) grid[j + 1][k + 1] = 2;
                            gCnt++;
                        }
                        else if (cur == 'B') {
                            dbug("<>. <> <> ", i, j, k);
                            for (int l = 0; l < 4; l++) {
                                dbug("<>. <> <> ", l, j + 1 + dr[l], k + 1 + dc[l]);
                                grid[j + 1 + dr[l]][k + 1 + dc[l]] = 1;
                            }
                        }
                    }
                }

                if (gCnt == 0) {
                    bw.write("Yes\n");
                    continue;
                }
                if (grid[rowCnt][colCnt] == 1) {
                    bw.write("No\n");
                    continue;
                }

                print(grid, rowCnt, colCnt);

                int endCnt = 0;
                int[][] q = new int[rowCnt * colCnt][2];
                boolean[][] visited = new boolean[rowCnt + 2][colCnt + 2];
                q[0][0] = rowCnt;
                q[0][1] = colCnt;
                int write = 1;
                visited[rowCnt][colCnt] = true;
                for (int read = 0; read < write; read++) {
                    int curRow = q[read][0];
                    int curCol = q[read][1];
                    dbug("<>) <> <> at <> <> ", read, q[read][0], q[read][1], curRow, curCol);

                    if (grid[curRow][curCol] == 2) endCnt++;

                    for (int j = 0; j < 4; j++) {
                        int newRow = curRow + dr[j];
                        int newCol = curCol + dc[j];
                        if (!visited[newRow][newCol] && grid[newRow][newCol] != 1) {
                            dbug("<>. <> <> <> ", j, write, newRow, newCol);
                            visited[newRow][newCol] = true;
                            q[write][0] = newRow;
                            q[write][1] = newCol;
                            write++;
                        }
                    }
                }

                if (i == 1) print(q, 0, 0);

                bw.write((endCnt == gCnt)? "Yes\n": "No\n");

                dbug("");
            }
            br.close();
            bw.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void dbug(String s, long ... a) { /*
        String[] line = s.split("<>");
        for (int i = 0; i < a.length; i++) {
            System.out.print(line[i] + a[i]);
        }
        System.out.println(line[a.length]); // */
    }

    public static void print(int[][] a, int rowCnt, int colCnt) { /*
        for (int i = 0; i <= rowCnt + 1; i++) {
            for (int j = 0; j <= colCnt + 1; j++) {
                System.out.print(a[i][j] + " ");
            }
            System.out.println();
        }
        System.out.println(); // */
    }
}