

def ckgd(A,i,j,n,m):
    if (i>0):
        if (A[i-1][j]=='G'):
            return 0
        if (A[i-1][j]=='.'):
            A[i-1][j]='#'

    if (j>0):
        if (A[i][j-1]=='G'):
            return 0
        if (A[i][j-1]=='.'):
            A[i][j-1]='#'

    if (i<n-1):
        if (A[i+1][j]=='G'):
            return 0
        if (A[i+1][j]=='.'):
            A[i+1][j]='#'
    
    if (j<m-1):
        if (A[i][j+1]=='G'):
            return 0
        if (A[i][j+1]=='.'):
            A[i][j+1]='#'

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

    f=1

    for i in range(n):
        for j in range(m):
            if (A[i][j]=='B'):
                if (ckgd(A,i,j,n,m)==0):
                    f=0
                    break
        
        if (f==0):
            break
                
    if (f==0):
        print("No")
    else:
        B=[[0 for i in range(m)] for j in range(n)]
        Q=[]
        if (A[n-1][m-1]!='#'):
            Q=[[n-1,m-1]]
            vis=[[0 for i in range(m)] for j in range(n)]
            B[n-1][m-1]='E'
            
        while(len(Q)!=0):
            a=Q.pop()
            i=a[0]
            j=a[1]
            vis[i][j]=1
            if (i>0 and A[i-1][j]!='#' and vis[i-1][j]==0):
                B[i-1][j]='E'
                Q.append([i-1,j])
            if (j>0 and A[i][j-1]!='#' and vis[i][j-1]==0):
                B[i][j-1]='E'
                Q.append([i,j-1])
            if (i<n-1 and A[i+1][j]!='#' and vis[i+1][j]==0):
                B[i+1][j]='E'
                Q.append([i+1,j])
            if (j<m-1 and A[i][j+1]!='#' and vis[i][j+1]==0):
                B[i][j+1]='E'
                Q.append([i,j+1])

        f=1
        for i in range(n):
            for j in range(m):
                if (A[i][j]=='G' and (B[i][j]!='E' or A[n-1][m-1]=='#')):
                    f=0
                    break
                elif (A[i][j]=='B' and B[i][j]=='E'):
                    f=0
                    break
            if (f==0):
                break
        if (f==0):
            print("No")
        else:
             print("Yes")
