from copy import deepcopy
def isPath(i,j,table,n,m,visited):
    visited[i][j]=1
    if(table[i][j]=="#"):
        return False
    if(i==(n-1) and j==(n-1)):
        return True
    i1=False
    i2=False
    i3 = False
    i4 = False
    if(i+1<n and visited[i+1][j]==0):
        i1 = isPath(i+1,j,table,n,m,visited)
    if(j+1<m and visited[i][j+1]==0):
        i2 = isPath(i,j+1,table,n,m,visited)
    if(i-1>=0 and visited[i-1][j] == 0):
        i3 = isPath(i-1,j,table,n,m,visited)
    if(j-1>=0 and visited[i][j-1] == 0):
        i4 = isPath(i,j-1,table,n,m,visited)
    return (i1 or i2 or i3 or i4)
t = int(input())
for i in range(t):
    n,m = map(int,input().split())
    table=[]
    for i in range(n):
        arr = list(input())
        table.append(arr)
    for i in range(n):
        for j in range(m):
            if(table[i][j]=="B"):
                if(i+1<n and table[i+1][j]=="."):
                    table[i+1][j]="#"
                if(i-1>=0 and table[i-1][j]=="."):
                    table[i-1][j]="#"
                if(j+1<m and table[i][j+1]=="."):
                    table[i][j+1]="#"
                if(j-1>=0 and table[i][j-1]=="."):
                    table[i-1][j]="#"
    visited = []
    for i in range(n):
        visited.append([0] * m)
    flagG=True
    flagB = True
    for i in range(n):
        for j in range(m):
            if(table[i][j]=='G'):
                vis = deepcopy(visited)
                if(isPath(i,j,table,n,m,vis)==False):
                    flagG=False
                    break
            elif(table[i][j]=="B"):
                vis = deepcopy(visited)
                if(isPath(i,j,table,n,m,vis)==True):
                    flagB=False
                    break
        if(flagG==False or flagB==False):
            break
    if(flagB and flagG):
        print("Yes")
    else:
        print("No")


