import sys
sys.setrecursionlimit(10**9)
t=int(input())
def dfs(N):
    global visited
    global d
    global m
    global n
    a=N%m
    b=N//m
    while (b+1)*m<=N:
        b+=1
    if d[b][a]=='#':
        return 0
    if N in visited:
        return 0
    visited.add(N)
    value=0
    if d[b][a]=='G':
        value+=1
    if N%m>0:
        value+=dfs(N-1)
    if N%m<m-1:
        value+=dfs(N+1)
    if N<(n-1)*m:
        value+=dfs(N+m)
    if N>=m:
        value+=dfs(N-m)
    return value
for _ in range(t):
    n,m=map(int,input().split())
    d=[]
    for i in range(n):
        s=input()
        d.append([])
        for j in s:
            d[-1].append(j)
    failflag=0
    gcount=0
    for i in range(n):
        for j in range(m):
            if d[i][j]=='B':
                if i>0 and d[i-1][j]=='.':
                    d[i-1][j]='#'
                if i>0 and d[i-1][j]=='G':
                    failflag=1
                if i<n-1 and d[i+1][j]=='.':
                    d[i+1][j]='#'
                if i<n-1 and d[i+1][j]=='G':
                    failflag=1
                if j>0 and d[i][j-1]=='.':
                    d[i][j-1]='#'
                if j>0 and d[i][j-1]=='G':
                    failflag=1
                if j<m-1 and d[i][j+1]=='.':
                    d[i][j+1]='#'
                if j<m-1 and d[i][j+1]=='G':
                    failflag=1
            if d[i][j]=='G':
                gcount+=1
    visited=set()
    if d[n-1][m-1]=='B':
        failflag=1
    if failflag==1:
        print('No')
        continue
    count2=dfs(n*m-1)
    if gcount==count2:
        print('Yes')
    else:
        print('No')