from sys import stdin
from collections import deque
input = stdin.readline

for _ in range(int(input())):
    n, m = map(int, input().split())
    a = []
    flag = "Yes"
    b, g = 0, 0

    for x in range(n):
        t = []

        for y in input().rstrip():
            t.append(y)
            
        a.append(t)

        b += t.count('B')
        g += t.count('G')

    if g == 0:
        print(flag)
        continue

    for x in range(n):
        for y in range(m):
            if a[x][y] == 'B':
                if x + 1 < n:
                    if a[x + 1][y] == '.':
                        a[x + 1][y] = '#'
                    elif a[x + 1][y] == 'G':
                        flag = "No"
                        break
                if x - 1 >= 0:
                    if a[x - 1][y] == '.':
                        a[x - 1][y] = '#'
                    elif a[x - 1][y] == 'G':
                        flag = "No"
                        break
                if y + 1 < m:
                    if a[x][y + 1] == '.':
                        a[x][y + 1] = '#'
                    elif a[x][y + 1] == 'G':
                        flag = "No"
                        break
                if y - 1 >= 0:
                    if a[x][y - 1] == '.':
                        a[x][y - 1] = '#'
                    elif a[x][y - 1] == 'G':
                        flag = "No"
                        break
        if flag == "No":
            break

    q = deque()
    chk = [[0] * 51 for x in range(51)]

    q.append([n - 1, m - 1])

    while len(q):
        nowx, nowy = q.popleft()

        if nowx + 1 < n and chk[nowx + 1][nowy] == 0:
            chk[nowx + 1][nowy] = 1

            if a[nowx + 1][nowy] == 'G':
                a[nowx + 1][nowy] == '.'
                g -= 1
                q.append([nowx + 1, nowy])
            elif a[nowx + 1][nowy] == '.':
                q.append([nowx + 1, nowy])
            elif a[nowx + 1][nowy] == 'B':
                flag = "No"
                break
        if nowx - 1 >= 0 and chk[nowx - 1][nowy] == 0:
            chk[nowx - 1][nowy] = 1

            if a[nowx - 1][nowy] == 'G':
                a[nowx - 1][nowy] == '.'
                g -= 1
                q.append([nowx - 1, nowy])
            elif a[nowx - 1][nowy] == '.':
                q.append([nowx - 1, nowy])
            elif a[nowx - 1][nowy] == 'B':
                flag = "No"
                break  
        if nowy + 1 < m and chk[nowx][nowy + 1] == 0:
            chk[nowx][nowy + 1] = 1

            if a[nowx][nowy + 1] == 'G':
                a[nowx][nowy + 1] == '.'
                g -= 1
                q.append([nowx, nowy + 1])
            elif a[nowx][nowy + 1] == '.':
                q.append([nowx, nowy + 1])
            elif a[nowx][nowy + 1] == 'B':
                flag = "No"
                break
        if nowy - 1 >= 0 and chk[nowx][nowy - 1] == 0:
            chk[nowx][nowy - 1] = 1

            if a[nowx][nowy - 1] == 'G':
                a[nowx][nowy - 1] == '.'
                g -= 1
                q.append([nowx, nowy - 1])
            elif a[nowx][nowy - 1] == '.':
                q.append([nowx, nowy - 1])
            elif a[nowx][nowy - 1] == 'B':
                flag = "No"
                break

    if g:
        flag = "No"

    print(flag)