from collections import deque
for _ in range(int(input())):
    wys, dlug = map(int, input().split())
    mapa = [[] for _ in range(wys)]
    i_good = 0
    czy = True
    for x in range(wys):
        mapa[x] = list(input())
    for x in range(wys):
        for y in range(dlug):
            if mapa[x][y] == "G":
                i_good += 1
            elif mapa[x][y] == "B":
                if mapa[min(x+1, wys - 1)][y] == "G":
                    czy = False
                    break
                elif mapa[x][min(y+1, dlug - 1)] == "G":
                    czy = False
                    break
                elif mapa[x][max(y-1, 0)] == "G":
                    czy = False
                    break
                elif mapa[max(x-1, 0)][y] == "G":
                    czy = False
                    break
                if mapa[min(x+1, wys - 1)][y] == ".":
                    mapa[min(x+1, wys - 1)][y] = "#"
                elif mapa[x][min(y+1, dlug - 1)] == ".":
                    mapa[x][min(y+1, dlug - 1)] = "#"
                elif mapa[x][max(y-1, 0)] == ".":
                    mapa[x][max(y-1, 0)] = "#"
                elif mapa[max(x-1, 0)][y] == ".":
                    mapa[max(x-1, 0)][y] = "#"
    kolejka = deque([[wys-1, dlug-1]])
    if mapa[-1][-1] == "B" or (mapa[-1][-1] == "#" and i_good > 0):
        czy = False
    odwiedzone = [[False for _ in range(dlug)] for _ in range(wys)]
    while kolejka:
        pkt = kolejka.pop()
        x = pkt[0]
        y = pkt[1]
        if (mapa[min(x+1, wys - 1)][y] == "." or mapa[min(x+1, wys - 1)][y] == "G") and not odwiedzone[min(x+1, wys - 1)][y]:
            kolejka.append([min(x+1, wys - 1),y])
            odwiedzone[min(x+1, wys - 1)][y] = True
        if (mapa[x][min(y+1, dlug - 1)] == "." or mapa[x][min(y+1, dlug - 1)] == "G") and not odwiedzone[x][min(y+1, dlug - 1)]:
            kolejka.append([x, min(y+1, dlug - 1)])
            odwiedzone[x][min(y+1, dlug - 1)] = True
        if (mapa[x][max(y-1, 0)] == "." or mapa[x][max(y-1, 0)] == "G") and not odwiedzone[x][max(y-1, 0)]:
            kolejka.append([x, max(y-1, 0)])
            odwiedzone[x][max(y-1, 0)] = True
        if (mapa[max(x-1, 0)][y] == "." or mapa[max(x-1, 0)][y] == "G") and not odwiedzone[max(x-1, 0)][y]:
            kolejka.append([max(x-1, 0), y])
            odwiedzone[max(x-1, 0)][y] = True
        if mapa[x][y] == "G":
            i_good -= 1
    if i_good:
        czy = False
    if czy:
        print("Yes")
    else:
        print("No")