import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main{
	public static boolean check(int i,int j,int arr[][])
	{
		int n=arr.length,m=arr[0].length;
		if(i>=n)
			return false;
		if(i<0)
			return false;
		if(j>=m)
			return false;
		if(j<0)
			return false;
		if(arr[i][j]==1)
			return false;
		if(arr[i][j]==-1)
			return false;
		return true;
	}
	public static void main(String[] args)   {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		while(t-->0)
		{
			int n=scan.nextInt();
			int m=scan.nextInt();
			int arr[][]=new int[n][m];
			ArrayList<Node> bad = new ArrayList<Node>();
			int count=0;
			for(int i=0;i<n;i++)
			{
				String temp = scan.next();
				for(int j=0;j<m;j++)
				{
					if(temp.charAt(j)=='.')
						arr[i][j]=0;
					else if(temp.charAt(j)=='#')
						arr[i][j]=1;
					else if(temp.charAt(j)=='G')
					{
						arr[i][j]=2;
						count++;
					}
					else {
						arr[i][j]=3;
						bad.add(new Node(i, j));
					}
				}
			}
			for(Node x:bad)
			{
				int i = x.i;
				int j = x.j;
				if (((i+1)<n)&&(arr[i+1][j]==0))
					arr[i+1][j]=1;
				if(((i-1)>=0)&&(arr[i-1][j]==0))
					arr[i-1][j]=1;
				if(((j+1)<m)&&(arr[i][j+1]==0))
					arr[i][j+1]=1;
				if(((j-1)>=0)&&(arr[i][j-1]==0))
					arr[i][j-1]=1;
			}
			Stack<Node> s = new Stack<Node>();
			if(arr[n-1][m-1]!=1)
				s.push(new Node(n-1, m-1));
			boolean poss=true;
			while(!s.isEmpty())
			{
				Node x = s.pop();
				int i=x.i,j=x.j;
				if(arr[i][j]==-1)
					continue;
				if(arr[i][j]==3)
					poss=false;
				if(arr[i][j]==2)
					count--;
				arr[i][j]=-1;
				if(check(i+1, j, arr))
					s.push(new Node(i+1, j));
				if(check(i-1, j, arr))
					s.push(new Node(i-1, j));
				if(check(i, j+1, arr))
					s.push(new Node(i, j+1));
				if(check(i, j-1, arr))
					s.push(new Node(i, j-1));
			}
			if((poss)&&(count==0))
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}
class Node{
	public int i,j;
	public Node(int i,int j) {
		this.i=i;
		this.j=j;
	}
}
