
import sys
input=sys.stdin.readline

    
for _ in range(int(input())):
    r,c=map(int,input().split())
    grid=[]
    for i in range(r):
        s=input()
        grid.append(list(s))
    f,cnt=0,0
    for i in range(r):
        for j in range(c):
            if(grid[i][j]=='B'):
                if(i+1<r):
                    cur=grid[i+1][j]
                    if(cur=='G'):
                        f=1
                        break
                    elif(cur=='.'):
                        grid[i+1][j]='#'
                if(i-1>=0):
                    cur=grid[i-1][j]
                    if(cur=='G'):
                        f=1
                        break
                    elif(cur=='.'):
                        grid[i-1][j]='#'
                if(j+1<c):
                    cur=grid[i][j+1]
                    if(cur=='G'):
                        f=1
                        break
                    elif(cur=='.'):
                        grid[i][j+1]='#'
                if(j-1>=0):
                    cur=grid[i][j-1]
                    if(cur=='G'):
                        f=1
                        break
                    elif(cur=='.'):
                        grid[i][j-1]='#'
            elif(grid[i][j]=='G'):
                cnt+=1
        if(f==1):
            break
    if(f==1 or (cnt>0 and grid[r-1][c-1]=='#')):
        print('No')
    else:
        q=[[r-1,c-1]]
        seen=set()
        seen.add((r-1,c-1))
        gc=0
        while(q):
            cur=q.pop(0)
            x,y=cur[0],cur[1]
            if(grid[x][y]=='G'):
                gc+=1
            elif(grid[x][y]=='#'):
                continue
            if(x-1>=0):
                if((x-1,y) not in seen):
                    seen.add((x-1,y))
                    q.append([x-1,y])
            if(y-1>=0):
                if((x,y-1) not in seen):
                    seen.add((x,y-1))
                    q.append([x,y-1])
            if(x+1<r):
                if((x+1,y) not in seen):
                    seen.add((x+1,y))
                    q.append([x+1,y])
            if(y+1<c):
                if((x,y+1) not in seen):
                    seen.add((x,y+1))
                    q.append([x,y+1])
        if(cnt==gc):
            print('Yes')
        else:
            print('No')
        