import sys;input=sys.stdin.readline
T, = map(int, input().split())
for _ in range(T):
    N, M = map(int, input().split())
    X = []
    gn = 0
    for _ in range(N):
        s = input().strip()
        X.append(s)
        gn += s.count('G')

    stack = [(N-1, M-1)]
    vs = set([(N-1, M-1)])
    ff = 0
    r = 0
    while stack:
        a, b = stack.pop()
#        print("t", a, b)
        cu = X[a][b]
        cs = []
        if a != N-1:
            cs.append((a+1, b))
        if a != 0:
            cs.append((a-1, b))
        if b != M-1:
            cs.append((a, b+1))
        if b != 0:
            cs.append((a, b-1))
        f = 0
        for c, d in cs:
            if X[c][d] == 'B':
                f=1
                break
        if f:
            if cu == 'G':
                ff = 1
                break
            continue
#        print("gg", cu, cs)
        if cu == 'G':
            r += 1
        for c, d in cs:
            if (c, d) in vs:
                continue
#            print(c, d, X[c][d])
            if X[c][d] != '#':
#                print(c, d, X[c][d])
                stack.append((c, d))
                vs.add((c, d))
#        print(r, gn)
    if ff or r != gn:
        print("No")
    else:
        print("Yes")


