FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
 
class DSU():
    def __init__(self, m, n):
        self.par = [i for i in range(m*n+1)]
        self.rank = [1 for i in range(m*n+1)]
    def find(self, x):
        if self.par[x] != x:
            self.par[x] = self.find(self.par[x])
        return self.par[x] 
    def union(self, x, y):
        par_x, par_y = self.find(x), self.find(y)
        if par_x == par_y:
            return 
        if self.rank[par_x] >self.rank[par_y]:
            self.par[par_y] = par_x
            self.rank[par_x]+= self.rank[par_y]
        else:
            self.par[par_x] = par_y
            self.rank[par_y] += self.rank[par_x]
        return 
    
    
def solve(m, n, arr):
    dsu = DSU(m,n)
    good = []
    bad = []
    for i in range(m):
        for j in range(n):
            if arr[i][j] == '.':
                for (nei_x, nei_y) in (i-1, j), (i, j-1):
                    if 0<=nei_x<m and 0<=nei_y<n and arr[nei_x][nei_y] =='.':
                        dsu.union(i*n+j, nei_x*n+nei_y)
            elif arr[i][j] =='#':
                dsu.union(i*n+j, m*n)
            elif arr[i][j] =='B':
                bad.append((i,j))
                dsu.union(i*n+j, m*n)
            elif arr[i][j] =='G':
                good.append((i,j))
    #add wall
    dead = set()
    for (i, j) in bad:
        for (nei_i, nei_j) in ((i-1, j), (i+1,j), (i, j-1), (i, j+1)):
            if 0<=nei_i<m and 0<=nei_j<n:
                if dsu.find(nei_i*n+nei_j) == dsu.find(m*n-1):
                    dead.add((nei_i, nei_j))
    for (i, j) in good:
        if dsu.find(i*n+j) == dsu.find(m*n):
            return False
        for (nei_i, nei_j) in ((i-1, j), (i+1,j), (i, j-1), (i, j+1)):
            if 0<=nei_i<m and 0<=nei_j<n:
                if arr[nei_i][nei_j] =='B':
                    return False
                if (dsu.find(nei_i*n+nei_j) == dsu.find(m*n-1) and (nei_i, nei_j) not in dead) or arr[nei_i][nei_j] =='G':
                    dsu.union(i*n+j, nei_i*n+nei_j)
    for (i, j) in good:
        if dsu.find(i*n+j) != dsu.find(m*n-1):
            return False
    return True
    

t = rri()
for _ in range(t):
    m, n = rrm()
    arr = []
    for _ in range(m):
        arr.append(list(rr()))
    if solve(m, n, arr):
        print('Yes')
    else:
        print('No')