n = int(input())
for i in range(n):
    r, s = [int(k) for k in input().split(' ')]
    maze = [input() for j in range(r)]
    good = set()
    bad = set()
    walls = set()
    for num, line in enumerate(maze):
        for mun, c in enumerate(line):
            component = maze[num][mun]
            if component == 'G':
                good.add((num, mun))
            elif component == 'B':
                bad.add((num, mun))
            elif component == '#':
                walls.add((num, mun))
    check = True
    if len(good) == 0:
        print('Yes')
        check = False
    for bg in bad:
        for x, y in [(0, -1), (0, +1), (-1, 0), (+1, 0)]:
            rx = bg[0]+x
            sy = bg[1]+y
            if (not min(rx, sy)<0) and (rx<r) and (sy<s):
                if maze[rx][sy] == 'G':
                    print('No')
                    check = False
                    break
                elif maze[rx][sy] == '.':
                    walls.add((rx, sy))
        if not check:
            break
    if not check:
        continue
    if ((r-1,s-1) in walls) or (maze[r-1][s-1] == 'B'):
        print('No')
    else:
        found_good = set()
        visited = set()
        visited.add((r-1, s-1))
        q = [(r-1, s-2), (r-2, s-1)]
        while (len(found_good) != len(good)) and (len(q) != 0):
            coor = q.pop()
            if maze[coor[0]][coor[1]] == 'G':
                found_good.add(coor)
                for x, y in [(0, -1), (0, +1), (-1, 0), (+1, 0)]:
                    rx = coor[0]+x
                    sy = coor[1]+y
                    if (not min(rx, sy)<0) and (rx<r) and (sy<s):
                        if not (rx, sy) in visited:
                            q.append((rx, sy))
                            visited.add((rx, sy))
            if (not coor in walls) and (not coor in bad):
                for x, y in [(0, -1), (0, +1), (-1, 0), (+1, 0)]:
                    rx = coor[0]+x
                    sy = coor[1]+y
                    if (not min(rx, sy)<0) and (rx<r) and (sy<s):
                        if not (rx, sy) in visited:
                            q.append((rx, sy))
                            visited.add((rx, sy))
        if len(found_good) == len(good):
            print('Yes')
        else:
            print('No')
