def valid(x,y,n,m):
    return x>=0 and x<=n-1 and y>=0 and y<=m-1
T = int(input())

for _ in range(T):
    n,m = map(int,input().split())
    arr = []
    for i in range(n):
        l = list(input())
        arr.append(l)
    neigh = [[0,1],[0,-1],[1,0],[-1,0]]
    for i in range(n):
        for j in range(m):
            if arr[i][j]=='B':
                for k in range(4):
                    x = i+neigh[k][0]
                    y = j+neigh[k][1]
                    if valid(x,y,n,m) and arr[x][y]=='.':
                        arr[x][y] = '#'
                        
    visited = [[0 for i in range(m)] for j in range(n)]
    que = []
    good = 1
    if arr[n-1][m-1]=='.':
        que.append([n-1,m-1])
        visited[n-1][m-1] = 1
    
    while len(que):
        curr = que.pop(0)
        for k in range(4):
            x = curr[0]+neigh[k][0]
            y = curr[1]+neigh[k][1]
            #print(x,y)
            if valid(x,y,n,m) and arr[x][y]!='#' and visited[x][y]!=1:
                #print(x,y)
                visited[x][y] = 1
                que.append([x,y])
    for i in range(n):
        for j in range(m):
            if (arr[i][j]=='G' and visited[i][j]!=1) or (arr[i][j]=='B' and visited[i][j]):
                good = 0
                break
    if good==1:
        print('Yes')
    else:
        print('No')
   
                
    
                
                