import sys
import copy

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    return


def getneighbors((a, b)):
    r = []
    if not a==0:
        r.append((a-1, b))
    if not b==0:
        r.append((a, b-1))
    if not a==n-1:
        r.append((a+1, b))
    if not b==m-1:
        r.append((a, b+1))
    return r


def bfs():
    ng = 0
    visited = {n * m-1}
    active = [(n-1,m-1)]
    active2 = []
    while active:
        # print(active)
        for a in active:
            if cells[a[0]][a[1]] == "G":
                ng+=1
            nbs = getneighbors((a[0], a[1]))
            for nb in nbs:
                if cells[nb[0]][nb[1]]!="#" and nb[0]*m + nb[1] not in visited:
                    visited.add(nb[0]*m + nb[1])
                    active2.append(nb)
        active = active2
        active2 = []
    if ng == og:
        print("Yes")
    else:
        print("No")
    return




for _ in xrange(int(raw_input())):
    n, m = RA()
    c = [list(RS()) for _ in range(n)]
    # for ci in c:
    #     print(ci)

    og = 0
    cells = copy.deepcopy(c)
    for i in range(n):
        for j in range(m):
            if c[i][j] == "G":
                og += 1
            if c[i][j] == "B":
                cells[i][j] = "#"
                for nb in getneighbors((i, j)):
                    cells[nb[0]][nb[1]] = "#"
    if ("B" in [c[n-2][m-1], c[n-1][m-2], c[n-1][m-1]]) or c[n-1][m-1] == "#":
        if og == 0 and c[n-1][m-1] != "B":
            print "Yes"
        else:
            print("No")
        continue

    # for ci in cells:
    #     print(ci)

    bfs()
