#from sys import setrecursionlimit as srl
import sys
if sys.subversion[0] == "PyPy":
    import io, atexit
    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
    
    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
mod = 10**9+7
RS = raw_input
RI = lambda x=int: map(x,RS().split())
RN = lambda x=int: x(RS())
''' ...................................................................... '''

def removeBad(mat,n,m):

    for i in xrange(1,n+1):
        for j in xrange(1,m+1):
            if mat[i][j]=='B':
                #mat[i][j] = '#'     # check
                
                if mat[i-1][j]=='G':
                    return 0
                else: mat[i-1][j]='#'
                
                if mat[i][j-1]=='G':
                    return 0
                else: mat[i][j-1]='#'

                if mat[i+1][j]=='G':
                    return 0
                elif mat[i+1][j]!='B':
                    mat[i+1][j]='#'

                if mat[i][j+1]=='G':
                    return 0
                elif mat[i][j+1]!='B':
                    mat[i][j+1]='#'

    return 1

def path(mat,n,m):
    yes = [[0]*(m+2) for i in xrange(n+2)]
    yes[n+1][m] = 1

    for i in xrange(n,0,-1):
        for j in xrange(m,0,-1):
            if mat[i][j]!='#':
                yes[i][j] = yes[i+1][j]|yes[i][j+1]

    return verify(mat,yes,n,m)

def verify(mat,path,n,m):

    for i in xrange(1,n+1):
        for j in xrange(1,m+1):
            if mat[i][j]=='G':
                value = path[i][j] | path[i-1][j] | path[i][j-1]
                if value<=0: return 0
            elif mat[i][j]=='B':
                value = path[i][j] | path[i-1][j] | path[i][j-1]
                if value>0: return 0       
    return 1
    
def main():
    n,m = RI()
    wall = ['#']*(m+2)
    mat = [wall] + [['#']+list(RS())+['#'] for i in xrange(n)]
    mat.append(wall)
    
    good,bad = 0,0

    for i in xrange(1,n+1):
        for j in xrange(1,m+1):
            if mat[i][j]=='G':
                good+=1
            elif mat[i][j]=='B':
                bad+=1
                
    if good==0: return 1
    if bad:
        if removeBad(mat,n,m)==0:
            return 0

    return path(mat,n,m)

for _ in xrange(RN()):
    print ('yes' if main() else 'no')
    
