import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')





from collections import deque


def solve(n, m, a):
    good = []
    bad = []
    for i in range(n):
        for j in range(m):
            if a[i][j] == 'G':
                good.append((i, j))
            if a[i][j] == 'B':
                bad.append((i, j))

    end_i = n-1
    end_j = m-1

    id_i = [-1, 0, 1, 0]
    id_j = [0, 1, 0, -1]

    ok = lambda x, y: x >= 0 and x < n and y >= 0 and y < m

    for bi, bj in bad:
        for k in range(4):
            bii = bi+id_i[k]
            bjj = bj+id_j[k]
            if not ok(bii, bjj):
                continue
            # if bii == end_i and bjj == end_j:
            #     return False
            for gi, gj in good:
                if bii == gi and bjj == gj:
                    return False
            a[bii][bjj] = '#'

    for i, g in enumerate(good):
        q = deque()
        q.append(g)
        found = False
        while q:
            vi, vj = q.popleft()
            if vi == end_i and vj == end_j:
                found = True
                break
            a[vi][vj] = i
            for k in range(4):
                vii = vi + id_i[k]
                vjj = vj + id_j[k]
                if not ok(vii, vjj):
                    continue
                if (a[vii][vjj] == '.' or a[vii][vjj] == 'G') and a[vii][vjj] != i:
                    q.append((vii, vjj))
        if not found:
            return False

    return True


def main():
    for _ in range(ri()):
        n, m = ria()
        a = []
        for _ in range(n):
            a.append([si for si in rs()])
        wi('Yes' if solve(n, m, a) else 'No')


if __name__ == '__main__':
    main()
