"""
Author: Q.E.D
Time: 2020-06-07 10:55:10
"""

d = [(-1, 0), (1, 0), (0, -1), (0, 1)]
def dfs(i, j, a):
    if a[i][j] == '#':
        return None
    v[i][j] = 1
    for (dx, dy) in d:
        x = i + dx
        y = j + dy
        if x >= 0 and x < n and y >= 0 and y < m and v[x][y] == 0:
            dfs(x, y, a)

T = int(input())
for _ in range(T):
    n, m = list(map(int, input().split()))  
    a = [list(input()) for _ in range(n)]
    
    g = 0
    for i in range(n):
        for j in range(m):
            if a[i][j] == 'G':
                g += 1
    
    for i in range(n):
        for j in range(m):
            if a[i][j] == 'B':
                for (dx, dy) in d:
                    x = i + dx
                    y = j + dy
                    if x >= 0 and x < n and y >= 0 and y < m and a[x][y] == '.':
                        a[x][y] = '#'
    
    v = [[0 for _ in range(m)] for _ in range(n)]
    dfs(n - 1, m - 1, a)
    vg, vb = 0, 0
    for i in range(n):
        for j in range(m):
            if v[i][j]:
                if a[i][j] == 'G':
                    vg += 1
                if a[i][j] == 'B':
                    vb += 1
    # print('\n'.join([''.join(a[i]) for i in range(n)]))
    # print('\n'.join([''.join(map(str, v[i])) for i in range(n)]))
    # print(g, vg, vb)
    ans = 'Yes' if (g == vg and vb == 0) else 'No'
    print(ans)
