def f(x,y,a,b,n,m,grid):
    if x==(n-1) and y==(m-1):
        return True
    if x>=n or y>=m:
        return False
    if x<0 or y<0:
        return False
    if grid[x][y]=='B':
        return False
    if grid[x][y]=='#':
        return False
    
    if ((x+1)!=a or y!=b) and f(x+1,y,x,y,n,m,grid):
        return True
    if (x!=a or (y+1)!=b) and f(x,y+1,x,y,n,m,grid):
        return True
    if ((x-1)!=a or y!=b) and f(x-1,y,x,y,n,m,grid):
        return True
    if (x!=a or (y-1)!=b) and f(x,y-1,x,y,n,m,grid):
        return True

    return False

def foo(x,y,n,m,grid):
    if x>0 :
        if grid[x-1][y]!='G':
            grid[x-1][y]='#'
        else:
            return False
    if x<(n-1) : 
        if grid[x+1][y]!='G':
            grid[x+1][y]='#'
        else:
            return False
    if y>0 :
        if grid[x][y-1]!='G':
            grid[x][y-1]='#'
        else:
            return False
    if y<(m-1) : 
        if grid[x][y+1]!='G':
            grid[x][y+1]='#'
        else:
            return False
    
    return True
        

for _ in range(int(input())):
    n,m=map(int,input().split())
    grid=[]
    for i in range(n):
        grid.append([x for x in input()])
    flag=True
    for i in range(n):
        for j in range(m):
            if grid[i][j]=='B':
                res = foo(i,j,n,m,grid)
                if res==False:
                    flag=False
                    break
        if flag==False:
            break
    if flag==False:
        print("No")
        continue
    
    for i in range(n):
        for j in range(m):
            if grid[i][j]=='G':
                res = f(i,j,i,j,n,m,grid)
                if res==False:
                    flag=False
                    break
        if flag==False:
            break
    if flag==False:
        print("No")
    else:
        print("Yes")
    




    
