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.*;

public class D implements Runnable {
	FastReader sc;
	PrintWriter out;
	long mod = (long)1e9 + 7;
	
	LinkedList<Integer> gr[];
	
	int gc = 0;
	int bc = 0;
	
	boolean vis[][];
	char mat[][];
	int n,m;
	
	void dfs(int i,int j)
	{
		if(i-1 >= 0 && mat[i-1][j] != '#' && !vis[i-1][j])
		{	
			if(mat[i-1][j] == 'G') gc++;
			if(mat[i-1][j] == 'B') bc++;
			
			vis[i-1][j] = true;
			dfs(i-1,j);
		}
		
		if(i+1 < n && mat[i+1][j] != '#' && !vis[i+1][j])
		{	
			if(mat[i+1][j] == 'G') gc++;
			if(mat[i+1][j] == 'B') bc++;
			
			vis[i+1][j] = true;
			dfs(i+1,j);
		}
		
		if(j-1 >= 0 && mat[i][j-1] != '#' && !vis[i][j-1])
		{	
			if(mat[i][j-1] == 'G') gc++;
			if(mat[i][j-1] == 'B') bc++;
			
			vis[i][j-1] = true;
			dfs(i,j-1);
		}
		
		if(j+1 < m && mat[i][j+1] != '#' && !vis[i][j+1])
		{	
			if(mat[i][j+1] == 'G') gc++;
			if(mat[i][j+1] == 'B') bc++;
			
			vis[i][j+1] = true;
			dfs(i,j+1);
		}
	}
	void solve() 
	{	
		int tc = sc.ni();
		outer: while(tc-- > 0)
		{
			n = sc.ni();
			m = sc.ni();
			
			mat = new char[n][m];
			vis = new boolean[n][m];
			
			int tgc = 0;
			int tbc = 0;
			for(int i = 0; i < n; i++)
			{
				mat[i] = sc.nln().toCharArray();
				for(int j = 0; j < m; j++)
				{
					if(mat[i][j] == 'G') tgc++;
					else if(mat[i][j] == 'B') tbc++;
				}
			}
			
			boolean pos = true;
			for(int i = 0; i < n; i++)
			{
				for(int j = 0; j < m; j++)
				{
					if(mat[i][j] == 'B')
					{
						if(i-1 >= 0 && mat[i-1][j] != 'G' && mat[i-1][j] != 'B')
						{
							mat[i-1][j] = '#';
						}
						if(i+1 < n && mat[i+1][j] != 'G' && mat[i+1][j] != 'B')
						{
							mat[i+1][j] = '#';
						}
						if(j-1 >= 0 && mat[i][j-1] != 'G' && mat[i][j-1] != 'B')
						{
							mat[i][j-1] = '#';
						}
						if(j+1 < m && mat[i][j+1] != 'G' && mat[i][j+1] != 'B')
						{
							mat[i][j+1] = '#';
						}
					}
				}
			}
			
			gc = 0;
			bc = 0;
			if(mat[n-1][m-1] != '#')
			{	
				vis[n-1][m-1] = true;
				dfs(n-1,m-1);
			}
			
			if(gc == tgc && bc == 0)
			{
				out.println("Yes");
			}
			else out.println("No");
			
		}
	}
	
	class Pair implements Comparable<Pair>
	{
		
		int x;
		int y;
		
		Pair(int x,int y)
		{
			this.x = x;
			this.y = y;
		}
		
		public int compareTo(Pair o) 
		{
			
			if(x != o.x)
			{
				if(x > o.x) return 1;  //increasing order
				else return -1;	
			}
			else
			{
				if(y > o.y) return 1;  //increasing order
				else return -1;	
			}
		}
	}

	public void run() 
	{
		out = new PrintWriter(System.out);
		sc = new FastReader();
		solve();
		out.flush();
	}

	public static void main(String[] args) 
	{
		new Thread(null, new D(), "Main", 1 << 28).start();
	}

	class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nd() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nln() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
        

		int[] nia(int n) {
			int[] ar = new int[n];
			for (int i = 0; i < n; i++)
				ar[i] = ni();
			return ar;
		}
		
		long[] nla(int n) {
			long[] ar = new long[n];
			for (int i = 0; i < n; i++)
				ar[i] = nl();
			return ar;
		}

	    
		int[][] nim(int n, int m) {
			int[][] ar = new int[n][];
			for (int i = 0; i < n; i++) {
				ar[i] = nia(m);
			}
			return ar;
		}

		long[][] nlm(int n, int m) {
			long[][] ar = new long[n][];
			for (int i = 0; i < n; i++) {
				ar[i] = nla(m);
			}
			return ar;
		}
		
		String reverse(String s)
		{
			StringBuilder r = new StringBuilder(s);
			return r.reverse().toString();
		}
		
		void merge1(int arr[], int l, int m, int r)
	    {
	        int n1 = m - l + 1;
	        int n2 = r - m;
	        int L[] = new int [n1];
	        int R[] = new int [n2];
	        for (int i=0; i<n1; ++i)
	            L[i] = arr[l + i];
	        for (int j=0; j<n2; ++j)
	            R[j] = arr[m + 1+ j];
	        int i = 0, j = 0;
	        int k = l;
	        while (i < n1 && j < n2)
	        {
	            if (L[i]<=R[j])
	            {
	                arr[k] = L[i];
	                i++;
	            }
	            else
	            {
	                arr[k] = R[j];
	                j++;
	            }
	            k++;
	        }
	        while (i < n1)
	        {
	            arr[k] = L[i];
	            i++;
	            k++;
	        }
	        while (j < n2)
	        {
	            arr[k] = R[j];
	            j++;
	            k++;
	        }
	    }
	    void sort1(int arr[], int l, int r)
	    {
	        if (l < r)
	        {
	            int m = (l+r)/2;
	            sort1(arr, l, m);
	            sort1(arr , m+1, r);
	            merge1(arr, l, m, r);
	        }
	    }
    }
}