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:
//package com.company;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;


public class Main {


    public static void showArr(int[] arr){
        int n=arr.length;
        for(int i=0;i<n;i++){
            System.out.print(arr[i]+" ");
        }
    }
    public static long gcd(long x, long y) {
        if (x == 0)
            return y;
        return gcd(y % x, x);
    }

    public static boolean twoPow (long n)
    {
        return n!=0 && ((n&(n-1)) == 0);
    }
    private static int[][] arr;
    public static void main(String args[]) throws IOException {
        Scanner in  = new Scanner(System.in);
        int t = in.nextInt();
//        int t=1;
        for (int jay = 0; jay < t; jay++) {
            int n = in.nextInt();
            int m = in.nextInt();
            arr = new int[n][m];
            int g=0;
            int x=0; int y=0;
            for(int i=0;i<n;i++){
                String ch = in.next();
                for(int j=0;j<m;j++){
//                    System.out.println(ch.charAt(j));
                    if(ch.charAt(j)=='.')arr[i][j]=0;
                    if(ch.charAt(j)=='#')arr[i][j]=1;
                    if(ch.charAt(j)=='B')arr[i][j]=2;
                    if(ch.charAt(j)=='G')arr[i][j]=3;
                }
            }
            int flag=0;

            for(int i=0;i<n;i++) {
                for (int j = 0; j < m; j++) {
                    if(arr[i][j]==3){
                        if(g==0){x=i;y=j;}
                        g+=1;
                    }
                    if(arr[i][j]==2){
                        boolean val = true;
                        val = val && modf(i+1,j);
                        val = val && modf(i-1,j);
                        val = val && modf(i,j+1);
                        val = val && modf(i,j-1);
                        if(!val) {
                            flag=1;
                            break;
                        }
                    }
                }
            }
            if(flag==1) System.out.println("No");
            else if(g==0) System.out.println("Yes");
            else {
                visited = new int[n][m];
                cnt = 0;
                hit = false;

                if(checkG(x,y)){
                    chekr(n,m,x,y);
                    if (hit && cnt==g) System.out.println("Yes");
                    else System.out.println("No");
                }
                else System.out.println("No");
            }
        }
    }

    private static boolean modf(int x, int y) {
        if(x>=0 && y>=0 && x<arr.length && y<arr[0].length) {
            if(arr[x][y]==0) arr[x][y] = 1;
            if(arr[x][y]==3) return false;
        }
        return true;
    }


    private static int cnt;
    private static boolean hit;
    private static int[][] visited;

    private static void chekr(int n, int m, int x, int y) {
//        System.out.println(x+" JAYYYYYYYYYYY "+y);

        int cur = arr[x][y];
        visited[x][y] = 1;

        if(cur==3) cnt+=1;
        if(x==n-1 && y==m-1){
            hit =  true;
        }

        if(checkG(x,y-1)) chekr(n,m,x,y-1);
        if(checkG(x,y+1)) chekr(n,m,x,y+1);
        if(checkG(x-1,y)) chekr(n,m,x-1,y);
        if(checkG(x+1,y)) chekr(n,m,x+1,y);

        return;
    }

    private static boolean checkG(int x, int i) {
        int n = arr.length;
        int m = arr[0].length;
        if(x>=0 && x<n && i>=0 && i<m && visited[x][i]==0 && arr[x][i]!=1 && arr[x][i]!=2) return true;
        return false;
    }
}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

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

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