# inp = open( 'file.txt' ).readline
inp = input
 

dirr = [ (-1 , 0) , (1 , 0) , (0 , -1) , (0 , 1) ]

for _ in range( int( inp() ) ):
    
    
    n , m = map( int , inp().strip().split(" ") )
    
    rows = []
    
    for __ in range(n):
        rows.append( list( inp().strip() ) )
    
    flag = True
    
    goods = 0
    
    for i in range(n):
        
        for j in range(m):
            
            if rows[i][j] == 'G':
                
                goods += 1
            
            elif rows[i][j] == 'B':
                
                #top
                if i > 0:
                    
                    if rows[i-1][j] == 'G':
                        flag = False
                        break
                    elif rows[i-1][j] == '.':
                        rows[i-1][j] = '#'
                        
                        
                #bot
                if i < n-1:
                    
                    if rows[i+1][j] == 'G':
                        flag = False
                        break
                    elif rows[i+1][j] == '.':
                        rows[i+1][j] = '#'
                        
                        
                #lef
                if j > 0:
                    
                    if rows[i][j-1] == 'G':
                        flag = False
                        break
                    elif rows[i][j-1] == '.':
                        rows[i][j-1] = '#'
                        
                        
                #rit
                if j < m-1:
                    
                    if rows[i][j+1] == 'G':
                        flag = False
                        break
                    elif rows[i][j+1] == '.':
                        rows[i][j+1] = '#'
    
    if not flag:
        print("No")
        continue
    
            
            
    
    backg = 0
    stack = [(n-1 , m-1)]
    vis = [ [False]*m for i in range(n) ]
    
    
    while len(stack) > 0:
        
        newtodo = []
        
        for stck in stack:
            
            a , b = stck
            
            if rows[a][b] == '#' or vis[a][b]:
                continue
            
            vis[a][b] = True
            
            if a > 0:
                newtodo.append((a-1, b))
            if b > 0:
                newtodo.append((a, b-1))
            if a < n - 1:
                newtodo.append((a+1, b))
            if b < m - 1:
                newtodo.append((a, b+1))
                    
        
        stack = newtodo
            

        
#     print(rows , vis)
    for i in range(n):
        
        for j in range(m):
            
            if rows[i][j] == 'G' and not vis[i][j]:
                flag = False
                break
    
    
    if flag:
        print("Yes")
    else:
        print("No")