import sys
input = lambda:sys.stdin.readline().strip()
def dfs(i,j): 
    vis[i][j] = True
    if i-1>=0 and mat[i-1][j]!=0:
        if not vis[i-1][j]:
            dfs(i-1,j)
    if i+1<n and mat[i+1][j]!=0:
        if not vis[i+1][j]:
            dfs(i+1,j)
    if j-1>=0 and mat[i][j-1]!=0:
        if not vis[i][j-1]:
            dfs(i,j-1)
    if j+1<m and mat[i][j+1]!=0:
        if not vis[i][j+1]:
            dfs(i,j+1)
t = int(input())
while t:
    t-=1
    n,m = map(int,input().split())
    mat = [[] for _ in range(n)]
    for i in range(n):
        inp = input()
        for j in inp:
            if j=='#':
                mat[i].append(0)
            elif j=='.':
                mat[i].append(1)
            elif j=='G':
                mat[i].append(2)
            elif j=='B':
                mat[i].append(3) 
    if mat[n-1][m-1]==3:
        print("No")
        continue 
    ok = True
    for i in range(n):
        for j in range(m):
            if mat[i][j]==3:
                if i-1>=0 and mat[i-1][j]==1:
                    mat[i-1][j] = 0
                if i+1<n and mat[i+1][j]==1:
                    mat[i+1][j] = 0
                if j-1>=0 and mat[i][j-1]==1:
                    mat[i][j-1] = 0
                if j+1<m and mat[i][j+1]==1:
                    mat[i][j+1] = 0
                if i-1>=0 and mat[i-1][j]==2:
                    ok = False 
                    break
                if i+1<n and mat[i+1][j]==2:
                    ok = False 
                    break
                if j-1>=0 and mat[i][j-1]==2:
                    ok = False 
                    break
                if j+1<m and mat[i][j+1]==2:
                    ok = False 
                    break
        if not ok:
            break 
    if ok==False:
        print("No")
    else:
        # for i in range(n):
        #     print(mat[i])
        ans = True
        vis = [[False]*m for _ in range(n)]
        if mat[n-1][m-1]==1:
            dfs(n-1,m-1)
        ans = True
        for i in range(n):
            for j in range(m):
                if (mat[i][j]==2 and not vis[i][j]) or (mat[i][j]==3 and vis[i][j]):
                    ans = False
                    break 
            if ans==False:
                break
        if ans:
            print("Yes")
        else:
            print("No")
                    
                    