def yn(arr,n,m):
    for i in range(n):
        for j in range(m):
            if(arr[i][j]=="B"):
                if(j-1>=0 and arr[i][j-1]!="G" and arr[i][j-1]!="B" ):
                    arr[i][j-1]="#"
                if(j+1<m and arr[i][j+1]!="G" and arr[i][j+1]!="B" ):
                    arr[i][j+1]="#"
                if(i-1>=0 and arr[i-1][j]!="G" and arr[i-1][j]!="B" ):
                    arr[i-1][j]="#"
                if(i+1<n and arr[i+1][j]!="G" and arr[i+1][j]!="B" ):
                    arr[i+1][j]="#"
                if(j-1>=0 and arr[i][j-1]=="G"):
                    return 1
                if(j+1<m and arr[i][j+1]=="G"):
                    return 1
                if(i-1>=0 and arr[i-1][j]=="G"):
                    return 1
                if(i+1<n and arr[i+1][j]=="G"):
                    return 1
    return 0
def dfs(i,j,n,m):
	if arr[i][j]=='#':
		return 0
 
	ans=0
	if arr[i][j]=='G':
		ans+=1
	arr[i][j]='#'
 
	if (i>0):
		ans+=dfs(i-1,j,n,m)
	if (i<n-1):
		ans+=dfs(i+1,j,n,m)
	if (j>0):
		ans+=dfs(i,j-1,n,m)
	if (j<m-1):
		ans+=dfs(i,j+1,n,m)
 
	return ans 
for _ in range(int(input())):
    n,m=map(int,input().split())
    arr=[]
    ng=0
    for i in range(n):
        arr.append(list(input()))
        ng+=arr[-1].count("G")
    if yn(arr,n,m):
        print("No")
    else:
        if(dfs(n-1,m-1,n,m)==ng):
            print("Yes")
        else:
            print("No")
    

    
    
            