def dfs(r, c, mat, visited):
    if mat[r][c] != '#' and not visited[r][c]:
        sum = 0
        if mat[r][c] == 'G':
            sum += 1
        visited[r][c] = True
        if r - 1 >= 0:
            sum += dfs(r - 1, c, mat, visited)
        if r + 1 < len(mat):
            sum += dfs(r + 1, c, mat, visited)
        if c - 1 >= 0:
            sum += dfs(r, c - 1, mat, visited)
        if c + 1 < len(mat[r]):
            sum += dfs(r, c + 1, mat, visited)
        return sum
    else:
        return 0


times = int(input())
for asdf in range(times):
    r, c = [int(i) for i in input().split()]
    mat = []
    visited = []
    for i in range(r):
        visited.append([])
        for j in range(c):
            visited[i].append(False)
    for i in range(r):
        mat.append([str(i) for i in input()])
    works = True
    gcnt = 0
    for i in range(r):
        for j in range(c):
            if mat[i][j] == 'B':
                if i + 1 < r and mat[i + 1][j] == '.':
                    mat[i + 1][j] = '#'
                elif i + 1 < r and mat[i + 1][j] == 'G':
                    works = False
                if i - 1 >= 0:
                    if mat[i - 1][j] == '.':
                        mat[i - 1][j] = '#'
                    elif mat[i - 1][j] == 'G':
                        works = False
                if j + 1 < c:
                    if mat[i][j + 1] == '.':
                        mat[i][j + 1] = '#'
                    elif mat[i][j + 1] == 'G':
                        works = False
                if j - 1 >= 0:
                    if mat[i][j - 1] == '.':
                        mat[i][j - 1] = '#'
                    elif mat[i][j - 1] == 'G':
                        works = False
            elif mat[i][j] == 'G':
                gcnt += 1
    if not works:
        print("No")
    elif dfs(r - 1, c - 1, mat, visited) == gcnt:
        print("Yes")
    else:
        print("No")
