import sys
def read(): return list(map(int, sys.stdin.readline().split()))

for t in range(int(input())):
    n,m = read()
    arr = []
    for i in range(n):
        arr.append(input())
    fail = 0
    done = 0
    bfound = 0
    gfound = 0
    for i in range(n):
        for j in range(m):    
            if arr[i][j] == "B":
                bfound = 1
                if j+1<=m-1:
                    if arr[i][j+1] == "G" or (i==n-1 and j+1==m-1):
                        fail = 1
                        break
                if j-1>=0:
                    if arr[i][j-1] == "G":
                        fail = 1
                        break
                if i+1<=n-1:
                    if arr[i+1][j] == "G" or (j == m-1 and i+1 ==n-1):
                        fail = 1
                        break
                if 0<=i-1:
                    if arr[i-1][j] == "G" :
                        #print("HeeD")
                        fail = 1
                        break
            elif arr[i][j] == "G": gfound = 1
        

        if fail and gfound: 
            done = 1
            print("No")
            break

    if not fail and not bfound :print("Yes")
    elif not done: print("Yes")


    
    