def valid(matrix, move):
    #move is a tuple
    row = len(matrix)
    col = len(matrix[0])
    if (move[0] < 0) or (move[1] < 0):
        return False
    else:
        return True

def output(matrix, pointer):
    if not valid(matrix, pointer):
        return True
    #pointer is a tuple of the location of cursor
    char = matrix[pointer[0]][pointer[1]]
    if char  == '.':
        if matrix[pointer[0] - 1][pointer[1]] == 'B' or matrix[pointer[0]][pointer[1] - 1] == 'B':
            matrix[pointer[0]][pointer[1]] = '#'
        else:
            matrix[pointer[0]][pointer[1]] = 'G'
        return (output(matrix, (pointer[0] -1, pointer[1]))) and (output(matrix, (pointer[0], pointer[1]-1)))
    elif char == 'G':
        return (output(matrix, (pointer[0] -1, pointer[1]))) and (output(matrix, (pointer[0], pointer[1]-1)))
    else:
        return True

def main(matrix):
    row = len(matrix)
    col = len(matrix[0])
    pointer = (row-1, col-1)
    output(matrix, pointer)
    for i in range(row):
        for j in range(col):
            if matrix[i][j] == 'G' and (i,j) != pointer:
                count = 0
                #check if at least one G is touching every G
                try:
                    if matrix[i+1][j] == 'G':
                        count += 1
                except IndexError:
                    pass
                try:
                    if matrix[i][j+1] == 'G':
                        count += 1
                except IndexError:
                    pass
                if count == 0:
                    return False
    return True
            
test_case = int(input())
res = []
for i in range(test_case):
    matrix = []
    lst = list(map(lambda elem: int(elem), input().split(" ")))
    [row, col] = lst
    matrix = []
    for i in range(row):
        l = list(input())
        matrix.append(l)
    res.append(main(matrix))

for i in res:
    if i == True:
        print("Yes")
    else:
        print("No")
    




