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 cp;
import java.io.*;
import java.util.*;
public class Cf_three {
	static int cur=0;
	static void bfs_trav(int x,int y,char[][] a,int n,int m){// x means x-coordinate
		Queue<Integer> que_x=new LinkedList<>();
		Queue<Integer> que_y=new LinkedList<>();
		int[][] vis=new int[n][m];
//		int[][] dist=new int[n][n];
		vis[x][y]=1;
		boolean reach_end=false;
		que_x.add(x);
		que_y.add(y);
		int[] dir_1= {-1,1,0,0};
		int[] dir_2= {0,0,-1,1};
		
		while(!que_x.isEmpty()) {
			//System.out.print(que_x.peek()+" "+que_y.peek());
			int v1=que_x.remove();
			int v2=que_y.remove();
//			if(v1==n-1 && v2==n-1) {
//				reach_end=true;
//				break;
//			}
			for (int i = 0; i < 4; i++) {
				if(v1+dir_1[i]>=0 && v1+dir_1[i]<n 
				&& v2+dir_2[i]>=0 && v2+dir_2[i]<m) {
					if(a[v1+dir_1[i]][v2+dir_2[i]]=='#')continue;//1 is obstacle
					if(vis[v1+dir_1[i]][v2+dir_2[i]]==0) {
						vis[v1+dir_1[i]][v2+dir_2[i]]=1;
						if(a[v1+dir_1[i]][v2+dir_2[i]]=='G')cur++;
//						dist[v1+dir_1[i]][v2+dir_2[i]]=dist[v1][v2]+1;
						que_x.add(v1+dir_1[i]);
						que_y.add(v2+dir_2[i]);
					}
				}
			}
		}
//		if(reach_end==true)return dist[n-1][n-1];
//		return (int)Double.POSITIVE_INFINITY; 
	}
	public static void main(String[] args) throws IOException {	
		PrintWriter out = new PrintWriter(System.out);
		Reader.init(System.in);
		Cf_three obj=new Cf_three();
		int t=Reader.nextInt();
		for (int ii = 0; ii < t; ii++) {
			int n=Reader.nextInt();
			int m=Reader.nextInt();
			char[][] a=new char[n][m];
			for (int j = 0; j < n; j++) {
				String str=Reader.next();
				char[] temp=str.toCharArray();
				a[j]=temp;
			}
			int tt=0;
			int tot=0;
//			System.out.println(Arrays.deepToString(a));
//			System.out.println(a[0][1]=='B');
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
//					System.out.println("oh");
					if(a[i][j]=='G')tot++;
					if(a[i][j]=='B') {
//						System.out.println("Helo "+i+" " +" "+j);
						if((i-1)>=0) {
							if(a[i-1][j]=='G') {
								tt=1;
								break;
							}
							if(a[i-1][j]!='B')a[i-1][j]='#';
						}
						if((i+1)<n) {
							if(a[i+1][j]=='G') {
								tt=1;
								break;
							}
							if(a[i+1][j]!='B')a[i+1][j]='#';
						}
						if((j-1)>=0) {
							if(a[i][j-1]=='G') {
								tt=1;
								break;
							}
							if(a[i][j-1]!='B')a[i][j-1]='#';
						}
						if((j+1)<m) {
							if(a[i][j+1]=='G') {
								tt=1;
								break;
							}
							if(a[i][j+1]!='B')a[i][j+1]='#';
						}
					}
				}
			}
			if(tt==1)System.out.println("No");
			else {
				obj.bfs_trav(n-1, m-1, a, n,m);
				if(tot==0)System.out.println("Yes");
				else if(tot!=cur)System.out.println("No");
				else if(a[n-1][m-1]=='#')System.out.println("No");
				else System.out.println("Yes");
//				if(tot==cur)System.out.println("Yes");
//				else System.out.println("No");
			}
			cur=0;
		}
		out.flush();
	}

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

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

}