from math import inf as inf
from math import *
from collections import *
import sys
input=sys.stdin.readline
def rec(r,i,j,vis):
    global co
    if(i<0 or i>n-1 or j<0 or j>m-1):
        return
    if(vis[i][j]):
        return
    vis[i][j]=1
    if(r[i][j]=='#'):
        return
    if(r[i][j]=='G'):
        co+=1
    rec(r,i+1,j,vis)
    rec(r,i-1,j,vis)
    rec(r,i,j+1,vis)
    rec(r,i,j-1,vis)
t=int(input())
global co
while(t):
    t-=1
    n,m=map(int,input().split())
    r=[]
    glob=0
    co=0
    for i in range(n):
        r.append(list(input().rstrip("\n")))
        glob+=r[i].count('G')
    for i in range(n):
        for j in range(m):
            if(r[i][j]=='B'):
                try:
                    if(r[i+1][j]=='.'):
                        r[i+1][j]='#'
                except:
                    pass
                try:
                    if(r[i-1][j]=='.'):
                        r[i-1][j]='#'
                except:
                    pass
                try:
                    if(r[i][j+1]=='.'):
                        r[i][j+1]='#'
                except:
                    pass
                try:
                    if(r[i][j-1]=='.'):
                        r[i][j-1]='#'
                except:
                    pass
    vis=[[0 for i in range(m)] for j in range(n)]
    rec(r,n-1,m-1,vis)
    if(co==glob):
        print("Yes")
    else:
        print("No")
    co=0
