from sys import stdin
from collections import deque


def fun():
    n, m = map(int, stdin.readline().split())
    lst = [list(stdin.readline()) for _ in range(n)]
    good = []
    for x in range(n):
        for y in range(m):
            if lst[x][y] == 'B':
                if x != 0:
                    if lst[x - 1][y] == 'G':
                        print('No')
                        return
                    elif lst[x - 1][y] == '.':
                        lst[x - 1][y] = '#'
                if x != n - 1:
                    if lst[x + 1][y] == 'G':
                        print('No')
                        return
                    elif lst[x + 1][y] == '.':
                        lst[x + 1][y] = '#'
                if y != 0:
                    if lst[x][y - 1] == 'G':
                        print('No')
                        return
                    elif lst[x][y - 1] == '.':
                        lst[x][y - 1] = '#'
                if y != m - 1:
                    if lst[x][y + 1] == 'G':
                        print('No')
                        return
                    elif lst[x][y + 1] == '.':
                        lst[x][y + 1] = '#'
            elif lst[x][y] == 'G':
                good.append((x, y))
    if lst[n - 1][m - 1] == 'B':
        print('No')
        return
    done = set()
    for r in good:
        if r in done:
            continue
        curr = deque([r])
        visi = {r}
        done.add(r)
        fl = 0
        while len(curr):
            x = curr.popleft()
            if x[0] != 0 and (x[0] - 1, x[1]) not in visi and lst[x[0] - 1][x[1]] == '.' or x[0] != 0 and (
            x[0] - 1, x[1]) not in visi and lst[x[0] - 1][x[1]] == 'G':
                curr.append((x[0] - 1, x[1]))
                visi.add((x[0] - 1, x[1]))
                if lst[x[0] - 1][x[1]] == 'G':
                    done.add((x[0]-1,x[1]))
            if x[0] != n - 1 and (x[0] + 1, x[1]) not in visi and lst[x[0] + 1][x[1]] == '.' or x[0] != n - 1 and (
            x[0] + 1, x[1]) not in visi and lst[x[0] + 1][x[1]] == 'G':
                curr.append((x[0] + 1, x[1]))
                visi.add((x[0] + 1, x[1]))
                if lst[x[0] + 1][x[1]] == 'G':
                    done.add((x[0]+1,x[1]))
            if x[1] != 0 and (x[0], x[1] - 1) not in visi and lst[x[0]][x[1] - 1] == '.' or x[1] != 0 and (
            x[0], x[1] - 1) not in visi and lst[x[0]][x[1] - 1] == 'G':
                curr.append((x[0], x[1] - 1))
                visi.add((x[0], x[1] - 1))
                if lst[x[0]][x[1]-1] == 'G':
                    done.add((x[0],x[1]-1))
            if x[1] != m - 1 and (x[0], x[1] + 1) not in visi and lst[x[0]][x[1] + 1] == '.' or x[1] != m - 1 and (
            x[0], x[1] + 1) not in visi and lst[x[0]][x[1] + 1] == 'G':
                curr.append((x[0], x[1] + 1))
                visi.add((x[0], x[1] + 1))
                if lst[x[0]][x[1]+1] == 'G':
                    done.add((x[0],x[1]+1))
            if (n - 1, m - 1) in visi:
                fl = 1
                break
        if not fl:
            print('No')
            return
    print('Yes')


for _ in range(int(stdin.readline())):
    fun()