import sys
input=sys.stdin.readline
t=int(input())
from collections import deque
for _ in range(t):
    n,m=list(map(int,input().split()))
    a=[]
    for _ in range(n):
        a.append(list(input()))
    for i in range(n):
        for j in range(m):
            if a[i][j]=='B':
                if i>0:
                    if a[i-1][j]=='.':
                        a[i - 1][j]='#'
                if j>0:
                    if a[i][j-1]=='.':
                        a[i ][j-1]='#'
                if i<n-1:
                    if a[i+1][j]=='.':
                        a[i + 1][j]='#'
                if j<m-1:
                    if a[i][j+1]=='.':
                        a[i][j+1]='#'

    dp=[[False for _ in range(m)] for _ in range(n)]

    dp[n-1][m-1]=True
    if a[n-1][m-1]!='#':
        stack=deque([(n-1,m-1)])
    else:
        stack=[]
    visited=set()
    counter=0
    while stack:
        node=stack.popleft()
        # print(node)
        visited.add(node)
        dp[node[0]][node[1]]=True
        if node[0]-1>=0 and (node[0]-1,node[1]) not in visited and a[node[0]-1][node[1]]!='#':
            stack.append((node[0]-1,node[1]))
        if node[0]+1<=n-1 and (node[0]+1,node[1]) not in visited and a[node[0]+1][node[1]]!='#':
            stack.append((node[0]+1,node[1]))
        if node[1]-1>=0 and (node[0],node[1]-1) not in visited and a[node[0]][node[1]-1]!='#':
            stack.append((node[0],node[1]-1))
        if node[1]+1<=m-1 and (node[0],node[1]+1) not in visited and a[node[0]][node[1]+1]!='#':
            stack.append((node[0],node[1]+1))
        counter+=1
        if counter>5000:
            for i in a:
                print(i)
            break
    ans=True
    # print(a)
    # for i in dp:
    #     print(i)

    for i in range(0,n):
        for j in range(0,m):
            if a[i][j]=='B':
                ans=ans and not dp[i][j]
            elif a[i][j]=='G':
                ans = ans and dp[i][j]
    if ans:
        print("Yes")
    else:
        print("No")


