from sys import stdin, stdout  
import collections
import heapq
import itertools
import functools
import math
import operator
import string

ALPHABET = string.ascii_lowercase
DIGITS = string.digits

def read_line():
    return stdin.readline().strip()
def read_int():
    return int(read_line())
def read_arr():
    return read_line().split(' ')
def read_int_arr():
    return [int(x) for x in read_arr()]
def query_interactive(s):
    print(s)
    stdout.flush()

def solve():
    n, m = read_int_arr()
    maze = []
    for _ in range(n):
        maze.append(list(read_line()))
    Gs = set()
    for r in range(n):
        for c in range(m):
            if maze[r][c] == 'B':
                for rr, cc in [(r + 1, c), (r, c + 1), (r - 1, c), (r, c - 1)]:
                    if 0<=rr<n and 0<=cc<m:
                        if maze[rr][cc] == 'B':
                            continue
                        if maze[rr][cc] == 'G':
                            print("NO")
                            return
                        else:
                            maze[rr][cc] = '#'
            elif maze[r][c] == 'G':
                Gs.add((r, c))
    if len(Gs) == 0:
        print("Yes")
        return
    # for r in maze:
    #     print(r)
    seen = set()
    found = set()
    bfs = collections.deque([(n - 1, m - 1)])
    while bfs:
        r, c = bfs.popleft()
        if (r, c) in seen:
            continue
        if not (0 <= r < n and 0 <= c < m):
            continue
        if maze[r][c] == '#':
            continue
        if (r, c) in Gs:
            found.add((r, c))
        seen.add((r, c))
        for rr, cc in [(r + 1, c), (r, c + 1), (r - 1, c), (r, c - 1)]:
            bfs.append((rr, cc))
    if len(found) != len(Gs):
        print("No")
    else:
        print("Yes")

def main():
    T = 1
    T = read_int()
    for _ in range(T):
        solve()

if __name__ == "__main__":
    main()