#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

for _ in range(inp()):
    n,m = ip()
    x = []
    gc = 0
    dx,dy = [1,-1,0,0],[0,0,-1,1]
    for i in range(n):
        t = list(input())
        gc += t.count('G')
        x.append(t)
    #[print(*i) for i in x]
    if gc == 0:
        print("Yes")
        continue
    flag = 0
    for i in range(n):
        for j in range(m):
            if x[i][j] == 'B':
                for k in range(4):
                    nx,ny = i+dx[k],j+dy[k]
                    if 0 <= nx < n and 0 <= ny < m:
                        if x[nx][ny] == '.':
                            x[nx][ny] = '#'
                        elif x[nx][ny] == 'G':
                            flag = 1
                            break
                if flag:
                    break
        if flag:
            break
    if flag:
        print("No")
        continue
    gset = set()
    vis = set()
    q = [(n-1,m-1)]
    vis.add((n-1,m-1))
    while q:
        #print(q)
        i,j = q.pop(0)
        if x[i][j] in ['#','B']:
            continue
        if x[i][j] == 'G':
            gset.add((i,j))
        for k in range(4):
            nx,ny = i+dx[k],j+dy[k]
            if 0 <= nx < n and 0 <= ny < m:
                #print("*",nx,ny)
                if (nx,ny) not in vis:
                    vis.add((nx,ny))
                    q.append((nx,ny))
    if len(gset) == gc:
        print("Yes")
    else:
        print("No")
    
    





    