from sys import stdin
input = stdin.readline

for _ in range(int(input())):
    n, m = map(int,input().split())
    text = []
    for i in range(n):
        temp = list(input())
        text.append(temp)

    flag = 0
    for i in range(n):
        for j in range(m):
            if text[i][j] != "B":
                continue
            if i > 0:
                if text[i-1][j] == ".":
                    text[i-1][j] = "#"
            if i < n-1:
                if text[i+1][j] == ".":
                    text[i+1][j] = "#"
            if j > 0:
                if text[i][j-1] == ".":
                    text[i][j-1] = "#"
            if j < m-1:
                if text[i][j+1] == ".":
                    text[i][j+1] = "#"
    arr = []
    for i in range(n):
        arr.append([0]*m)
    queue = []
    if text[n-1][m-1] == ".":
        queue.append((n-1,m-1))
    while queue:
        curr = queue.pop()
        (i,j) = curr
        arr[i][j] = 1
        if i > 0:
            if text[i - 1][j] != "#" and arr[i - 1][j] == 0:
                queue.append((i-1,j))

        if i < n-1:
            if text[i + 1][j] != "#" and arr[i + 1][j] == 0:
                queue.append((i + 1, j))

        if j > 0:
            if text[i][j - 1] != "#" and arr[i][j - 1] == 0:
                queue.append((i, j - 1))

        if j < m-1:
            if text[i][j + 1] != "#" and arr[i][j + 1] == 0:
                queue.append((i, j + 1))

    for i in range(n):
        for j in range(m):
            if text[i][j] == "B":
                if arr[i][j] == 1:
                    flag = 1
                    break
            if text[i][j] == "G":
                if arr[i][j] == 0:
                    flag = 1
                    break
    if flag:
        print("No")
    else:
        print("Yes")