# import sys
# input = sys.stdin.readline
import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
for _ in range(int(input())):
    n,m = map(int, input().split())
    a = [[0]*(m+2)]
    for i in range(1,n+1):
        a.append([0] + [j for j in input()] + [0])
    a.append([0]*(m+2))
    # print(a)
    ch = True
    d = []
    for i in range(1,n+1):
        for j in range(1,m+1):
            if a[i][j]=='B':
                if a[i+1][j]=='G' or a[i-1][j]=='G' or a[i][j+1]=='G' or a[i][j-1]=='G':
                    ch = False
                    break
                if a[i+1][j]!='G' and a[i+1][j]!='B':
                    a[i+1][j] = '#'
                if a[i-1][j]!='G' and a[i-1][j]!='B':
                    a[i-1][j] = '#'
                if a[i][j+1]!='G' and a[i][j+1]!='B':
                    a[i][j+1] = '#'
                if a[i][j-1]!='G' and a[i][j-1]!='B':
                    a[i][j-1] = '#'

            elif a[i][j]=='G':
                d.append([i,j])

        if not ch:
            break
    if a[n][m]!='.' and d!=[]:
        print("No")
    elif ch:
        l = [0,0]
        answer = 0
        stk = deque()
        p = False
        for u in d:
            dfs = []
            v = 1
            fl = True
            p = False
            dfs.append(u)
            while v:
                i = dfs[-1][0]
                j = dfs[-1][1]
                fl = True
                if (a[i+1][j]=='.' or a[i+1][j]=='G') and ([i+1,j] not in dfs):
                    stk.append([i,j])
                    # l = [i+1,j]
                    fl = False
                    dfs.append([i+1,j])

                elif (a[i][j+1]=='.' or a[i][j+1]=='G') and ([i,j+1] not in dfs):
                    stk.append([i,j])
                    # l = [i,j+1]
                    fl = False
                    dfs.append([i,j+1])

                elif (a[i-1][j]=='.' or a[i-1][j]=='G') and ([i-1,j] not in dfs):
                    stk.append([i,j])
                    # l = [i-1,j]
                    fl = False
                    dfs.append([i-1,j])

                elif (a[i][j-1]=='.' or a[i][j-1]=='G') and ([i,j-1] not in dfs):
                    stk.append([i,j])
                    # l = [i,j-1]
                    fl = False
                    dfs.append([i,j-1])

                if fl:
                    if dfs[-1] == [n,m]:
                        answer+=1
                        break
                    else:
                        if len(stk)==0:
                            print("No")
                            p = True
                            break
                        else:
                            dfs.append(stk[-1])
                            stk.pop()
                            
                    fl = True


            if p:
                break
        if not p:
            if answer==len(d):
                print("Yes")
            else:
                print("No")
    elif not ch:
        print("No")