import sys
sys.setrecursionlimit(10**6)

def dfs(i,j,visited,s):
    if (i,j) not in visited:
        visited.add((i,j))

        if (i-1,j) not in s:
            if i - 1 >= 0:
                dfs(i - 1, j, visited, s)

        if (i+1,j) not in s:
            if i + 1 <= n:
                dfs(i + 1, j, visited, s)

        if (i,j-1) not in s:
            if j - 1 >= 0:
                dfs(i, j-1, visited, s)

        if (i,j+1) not in s:
            if j+1 <= m:
                dfs(i, j+1,visited, s)


    return


for _ in range(int(input())):
    n,m = map(int,input().split())
    #d = {}
    s = set()
    b = set()
    g = set()
    h = set()
    i = 0
    f = 0
    while(i < n):
        j = 0
        q = input()
        while(j < m):
            x = q[j]
            if x == "#":
                s.add((i,j))

            if x == "G":
                g.add((i,j))
                f = 1

            if x == "B":
                b.add((i,j))

            if x == ".":
                h.add((i,j))

            j = j+1

        i = i+1

    n = n-1
    m = m-1
    #d[(n,m)] = 'G'
    g.add((n,m))

    if f == 0:
        print("Yes")
        continue

    else:
        f = 0
        for k in b:
            #ei = k[0]
            #ej = k[1]
            e11 = k[0]
            e12 = k[1]+1
            e21 = k[0]
            e22 = k[1]-1
            e31 = k[0]+1
            e32 = k[1]
            e41 = k[0]-1
            e42 = k[1]
            if (e11,e12) in g:
                f = 1
                break

            if (e11,e12) in h:
                s.add((e11,e12))

            if (e21,e22) in g:
                f = 1
                break

            if (e21,e22) in h:
                s.add((e21,e22))

            if (e31,e32) in g:
                f = 1
                break

            if (e31,e32) in h:
                s.add((e31,e32))

            if (e41,e42) in g:
                f = 1
                break

            if (e41,e42) in h:
                s.add((e41,e42))

        if f == 1:
            print("No")
            continue

        r = 1
        #print(s)
        g.remove((n,m))
        u = set()
        dfs(n,m,u, s)
        for i in g:
            if (i[0],i[1]) not in u:
                r = 0
                break

        if r == 0:
            print("No")

        else:
            print("Yes")