T = int(input().strip())
for t in range(T):
    n, m = list(map(int, input().split()))
    field = [[1] * (m + 2) for _ in range(n+2)]
    bads = []
    goods = []
    for row in range(n):
        cr = input().strip()
        for col, cell in enumerate(cr):
            if cell == '#':
                field[row +1][col +1] = 1
            elif cell == 'B':
                bads.append((row +1, col +1))
                field[row + 1][col + 1] = 0
            elif cell == 'G':
                goods.append((row +1, col +1))
                field[row + 1][col + 1] = 0
            else:
                field[row +1][col +1] = 0
    if len(goods) == 0 or len(bads) == 0:
        print('Yes')
        continue

    # print('before:')
    # for r in field:
    #     print("".join(str(c) for c in r))


    for b in bads:
        for shiftx, shifty in [(1,0), (-1, 0), (0,1), (0, -1)]:
            field[b[0]+ shiftx][ b[1] +shifty] = 1

    # print('after:')
    # for r in field:
    #     print("".join(str(c) for c in r))

    stk = [(n,m)]

    if field[n][m] == 1:
        print('No')
        continue
    start = 0
    field[n][m] = 2
    while start < len(stk):
        b = stk[start]
        for shiftx, shifty in [(1,0), (-1, 0), (0,1), (0, -1)]:
            if field[b[0]+ shiftx] [ b[1] +shifty] == 0:
                field[b[0] + shiftx][b[1] + shifty] = 2
                stk.append((b[0] + shiftx,b[1] + shifty))
        start += 1
    good = True
    for b in goods:
        if field[b[0]][b[1]] != 2:
            good = False
            break
    if good:
        print('Yes')
    else:
        print('No')


    # print('passed:')
    # for r in field:
    #     print("".join(str(c) for c in r))

