import java.util.*;
import java.io.*;
public class Solve_The_Maze 
{
	static class Pair {
		int  x;
		int y;

		// Constructor 
		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
	
	static int val(int i,int j,int n)
	{
		return i*n+j;
	}
	public static boolean check(int i,int j,int n,int m)
	{
		if(i>=0 && i<n && j<m && j>=0)
		{
			return true;
		}
		return false;
	}
	
	public static boolean bfs(char ch[][],int n,int m,int i,int j,int v[][])
	{
		Queue<Pair> arr=new LinkedList<Pair>();
		arr.add(new Pair(i,j));

		v[i][j]=1;
		while(arr.isEmpty()==false)
		{
			Pair t=arr.peek();
			arr.poll();
			int p=t.x;int o=t.y;
	       
			if(p==n-1 && o==m-1)
		     {
		    	 return true;
		     }
		    	 
		    if(check(p+1,o,n,m)==true && (ch[p+1][o]=='.' || ch[p+1][o]=='G') && v[p+1][o]==0)
		    {
		        arr.add(new Pair(p+1,o));
		        v[p+1][o]=1;
		    }
		    if(check(p-1,o,n,m)==true && (ch[p-1][o]=='.' || ch[p-1][o]=='G') && v[p-1][o]==0)
		    {
		        arr.add(new Pair(p-1,o));
		        v[p-1][o]=1;
		    }
		    
		    if(check(p,o+1,n,m)==true && (ch[p][o+1]=='.' || ch[p][o+1]=='G') && v[p][o+1]==0)
		    {
		    
		        arr.add(new Pair(p,o+1));
		        v[p][o+1]=1;
		    }
		    if(check(p,o-1,n,m)==true && (ch[p][o-1]=='.' || ch[p][o-1]=='G') && v[p][o-1]==0)
		    {
		    	
		        arr.add(new Pair(p,o-1));
		        v[p][o-1]=1;
		    }
		     
		}
		return false;
		
	}
	public static void process()throws IOException
	{
		int n=I();int m=I();
		char ch[][]=new char[n][m];
		for(int i=0;i<n;i++)
		{
			String s=S();
			for(int j=0;j<s.length();j++)
			{
				ch[i][j]=s.charAt(j);
			}
		}
		ArrayList<Pair> arr=new ArrayList<Pair>();
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(ch[i][j]=='G')
				{
					arr.add(new Pair(i,j));
					}
				else
				if(ch[i][j]=='B')
				{
					if(check(i+1,j,n,m)==true && ch[i+1][j]!='G')
					{
						ch[i+1][j]='#';
					}
					if(check(i-1,j,n,m)==true  && ch[i-1][j]!='G')
					{
						ch[i-1][j]='#';
					}
					if(check(i,j+1,n,m)==true  && ch[i][j+1]!='G')
					{
						ch[i][j+1]='#';
					}
					if(check(i,j-1,n,m)==true  && ch[i][j-1]!='G')
					{
						ch[i][j-1]='#';
					}
				}
			}
		}
	
	  
		int v[][]=new int[n][m];int c=0;
	
		for(int k=0;k<arr.size();k++)
		{
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<m;j++)
				{
					v[i][j]=0;
				}
			}
			Pair h=arr.get(k);
		    int i=h.x;int j=h.y;
		  
		    if(bfs(ch,n,m,i,j,v))
		    {
		    	c++;
		    }
		}

		if(c==arr.size() && arr.size()!=0)
	{
		pn("Yes");
	}
	else
	{
		pn("No");
	}
		
		
	}
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static void pn(Object o){out.println(o);out.flush();}
	static void p(Object o){out.print(o);out.flush();}
	static void pni(Object o){out.println(o);System.out.flush();}
	static int I() throws IOException{return sc.nextInt();}
	static long L() throws IOException{return sc.nextLong();}
	static double D() throws IOException{return sc.nextDouble();}
	static String S() throws IOException{return sc.next();}
	static char C() throws IOException{return sc.next().charAt(0);}
	static int[] Ai(int n) throws IOException{int[] arr = new int[n];for (int i = 0; i < n; i++)arr[i] = I();return arr;}
	static String[] As(int n) throws IOException{String s[] = new String[n];for (int i = 0; i < n; i++)s[i] = S();return s;}
	static long[] Al(int n) throws IOException {long[] arr = new long[n];for (int i = 0; i < n; i++)arr[i] = L();return arr;}
	static void dyn(int dp[][],int n,int m,int z)throws IOException {for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ dp[i][j]=z;}} }
	
//	*--------------------------------------------------------------------------------------------------------------------------------*//
	static class AnotherReader {BufferedReader br;StringTokenizer st;AnotherReader() throws FileNotFoundException {br = new BufferedReader(new InputStreamReader(System.in));}
	AnotherReader(int a) throws FileNotFoundException {br = new BufferedReader(new FileReader("input.txt"));}
	String next() throws IOException{while (st == null || !st.hasMoreElements()) {try {st = new StringTokenizer(br.readLine());} catch (IOException e) {e.printStackTrace();}}return st.nextToken();}
	int nextInt() throws IOException {return Integer.parseInt(next());}
	long nextLong() throws IOException {return Long.parseLong(next());}
	double nextDouble() throws IOException {return Double.parseDouble(next());}
	String nextLine() throws IOException {String str = "";try {str = br.readLine();} catch (IOException e) {e.printStackTrace();}return str;}}
	public static void main(String[] args)throws IOException{try{boolean oj=true;if(oj==true)
	{AnotherReader sk=new AnotherReader();PrintWriter out=new PrintWriter(System.out);}
	else
	{AnotherReader sk=new AnotherReader(100);out=new PrintWriter("output.txt");}
	long T=L();while(T-->0)
	{process();}out.flush();out.close();}catch(Exception e){return;}}}
//*-----------------------------------------------------------------------------------------------------------------------------------*//
	