def answer(n,m,A):
    if A[n-1][m-1]=="B":
        return "No"
    count=0
    for i in range(n):
        for j in range(m):
            if A[i][j]=="B":
                if (j-1>=0 and A[i][j-1] =="G") or (j+1<m and A[i][j+1]=="G") or (i-1>=0 and A[i-1][j]=="G") or (i+1<n and A[i+1][j]=="G"):
                    return "No"
                else:
                    if j-1>=0 and A[i][j-1] ==".":
                        A[i][j-1]="#"
                    if j+1<m and A[i][j+1]==".":
                        A[i][j+1]="#"
                    if i-1>=0 and A[i-1][j]==".":
                        A[i-1][j]="#" 
                    if i+1<n and A[i+1][j]==".":
                        A[i+1][j]="#"
            if A[i][j]=="G":
                count+=1
    if A[n-1][m-1]=="#" and count!=0:
        return "No"
    if count==0:
        return "Yes"
    dp=[[0 for i in range(m)] for j in range(n)]
    s=[[n-1,m-1]]
    while len(s)>0:
        l=s.pop()
        r=l[0]
        c=l[1]
        if c+1<m and A[r][c+1]!="#" and dp[r][c+1]==0:
            s.append([r,c+1])
        if c-1>=0 and A[r][c-1]!="#" and dp[r][c-1]==0:
            s.append([r,c-1])
        if r-1>=0 and A[r-1][c]!="#" and dp[r-1][c]==0:
            s.append([r-1,c])
        if r+1<n and A[r+1][c]!="#" and dp[r+1][c]==0:
            s.append([r+1,c])
        dp[r][c]=1
    for i in range(n):
        for j in range(m):
            if A[i][j]=="G" and dp[i][j]!=1:
                return "No"
    return "Yes"
        
t=int(input())
for i in range(t):
    n,m=map(int,input().split())
    l=[]
    for i in range(n):
        l.append(list(input()))
 
    print(answer(n,m,l))