def is_valid(i, j):
    return 0 <= i < n and 0 <= j < m

def dfs(i, j):
    if not is_valid(i, j) or v[i][j] or a[i][j] == '#':
        return False

    if (i, j) == (n-1, m-1):
        return True

    v[i][j] = True

    return dfs(i-1, j) or dfs(i+1, j) or dfs(i, j-1) or dfs(i, j+1)

for _ in range(int(input())):
    n, m = map(int, input().split())

    a = []

    for _ in range(n):
        a.append(list(input()))

    flag = False

    for i in range(n):
        for j in range(m):
            if a[i][j] != 'B':
                continue

            if is_valid(i-1, j):
                if a[i-1][j] == 'G':
                    flag = True
                    break

                if a[i-1][j] != 'B':
                    a[i-1][j] = '#'

            if is_valid(i+1, j):
                if a[i+1][j] == 'G':
                    flag = True
                    break

                if a[i+1][j] != 'B':
                    a[i+1][j] = '#'

            if is_valid(i, j-1):
                if a[i][j-1] == 'G':
                    flag = True
                    break

                if a[i][j-1] != 'B':
                    a[i][j-1] = '#'

            if is_valid(i-1, j):
                if a[i][j+1] == 'G':
                    flag = True
                    break

                if a[i][j+1] != 'B':
                    a[i][j+1] = '#'

        if flag:
            break

    if flag:
        print('No')
        continue

    for i in range(n):
        for j in range(m):
            if a[i][j] == 'G':
                v = [[False] * m for _ in range(n)]

                if not dfs(i, j):
                    flag = True
                    break

        if flag:
            break

    if flag:
        print('No')
    else:
        print('Yes')