#!/usr/bin/env python3

from collections import deque

t = int(input())
for _ in range(t):
    n, m = map(int, input().split())
    a = []
    for i in range(n):
        a.append(list(input()))

    g = []
    b = []
    for i in range(n):
        for j in range(m):
            if a[i][j] == 'G':
                g.append((i, j))
            elif a[i][j] == 'B':
                b.append((i, j))
    if len(g) == 0:
        print("Yes")
        continue

    possible = True
    for b_i in b:
        i, j = b_i
        if i != 0 and a[i - 1][j] == '.':
            a[i - 1][j] = '#'
        if i != n - 1 and a[i + 1][j] == '.':
            a[i + 1][j] = '#'
        if j != 0 and a[i][j - 1] == '.':
            a[i][j - 1] = '#'
        if j != m - 1 and a[i][j + 1] == '.':
            a[i][j + 1] = '#'

    if a[n - 1][m - 1] == '#':
        print("No")
        continue

    visited = set()
    d = deque()
    d.append((n - 1, m - 1))
    visited.add((n - 1, m - 1))
    while len(d) != 0:
        i, j = d[0]
        d.popleft()

        if a[i][j] == 'G':
            g.remove((i, j))

        if a[i][j] == 'B':
            possible = False
            break

        if i != 0 and a[i - 1][j] != '#' and not (i - 1, j) in visited:
            d.append((i - 1, j))
            visited.add((i - 1, j))
        if i != n - 1 and a[i + 1][j] != '#' and not (i + 1, j) in visited:
            d.append((i + 1, j))
            visited.add((i + 1, j))
        if j != 0 and a[i][j - 1] != '#' and not (i, j - 1) in visited:
            d.append((i, j - 1))
            visited.add((i, j - 1))
        if j != m - 1 and a[i][j + 1] != '#' and not (i, j + 1) in visited:
            d.append((i, j + 1))
            visited.add((i, j + 1))

    if not possible or len(g) != 0:
        print("No")
    else:
        print("Yes")
