
from sys import stdin, stdout
import heapq as hq
from collections import defaultdict

t = int(input())
for tc in range(t):
    #n = int(stdin.readline())
    n,m = list(map(int, stdin.readline().split()))
    mat=[]
    boundery=["#" for _ in range(m+2)]
    mat.append(boundery)
    for nc in range(n):
        instr=list(stdin.readline().strip())
        mat.append(["#"]+instr+["#"])
    mat.append(boundery)

    n+=2
    m+=2
    valid=True

    bcount,gcount=0,0

    for row in mat:
        for char in row:
            if char=="B":
                bcount+=1
            elif char=="G":
                gcount+=1
    if gcount==0:
        pass
    else:
        if bcount>0:
            for i in range(n):
                for j in range(m):
                    if mat[i][j] == "B":
                        if mat[i-1][j]=="G":
                            valid=False
                        elif mat[i-1][j]=="B":
                            pass
                        else:
                            mat[i - 1][j] = "#"

                        if mat[i+1][j]=="G":
                            valid=False
                        elif mat[i+1][j]=="B":
                            pass
                        else:
                            mat[i + 1][j] = "#"

                        if mat[i][j-1]=="G":
                            valid=False
                        elif mat[i][j-1]=="B":
                            pass
                        else:
                            mat[i][j-1] = "#"

                        if mat[i][j+1]=="G":
                            valid=False
                        elif mat[i][j+1]=="B":
                            pass
                        else:
                            mat[i][j+1] = "#"
        found={(n-2, m-2)}
        curgen=[(n-2,m-2)]
        nextgen=[]
        if mat[n-2][m-2]=="#":
            curgen=[]
            valid=False
        while len(curgen)+len(nextgen)>0:
            if len(curgen)==0:
                curgen=nextgen
                nextgen=[]
            i,j=curgen[0]
            if mat[i][j]=="G":
                mat[i][j] = "."
            if mat[i][j]=="B":
                valid=False

            if mat[i - 1][j] in (".","G") and (i-1,j) not in found:
                found.add((i-1,j))
                nextgen.append((i-1,j))
            if mat[i + 1][j] in (".", "G") and (i + 1, j) not in found:
                found.add((i + 1, j))
                nextgen.append((i + 1, j))
            if mat[i][j-1] in (".", "G") and (i, j - 1) not in found:
                found.add((i, j - 1))
                nextgen.append((i, j - 1))
            if mat[i][j + 1] in (".", "G") and (i, j + 1) not in found:
                found.add((i, j + 1))
                nextgen.append((i, j + 1))
            curgen=curgen[1:]

        for i in range(n):
            for j in range(m):
                if mat[i][j] == "G":
                        valid = False


    if valid:
        res="Yes"
    else:
        res="No"
    stdout.write(str(res) + "\n")