"""T=int(input())
for _ in range(0,T):
    n=int(input())
    a,b=map(int,input().split())
    s=input()
    s=[int(x) for x in input().split()]
    for i in range(0,len(s)):
        a,b=map(int,input().split())"""


T=int(input())
for _ in range(0,T):
    n,m=map(int,input().split())
    L=[]
    vis=[]
    org=0
    for i in range(n):
        s=input()
        h=[]
        h2=[]
        for j in range(0,len(s)):
            if(s[j]=='G'):
                org+=1
                
            h.append(s[j])
            h2.append(False)
            
        L.append(h)
        vis.append(h2)

    temp=0
    for i in range(n):
        for j in range(m):
            if(L[i][j]=='B'):
                L[i][j]='#'
                if(i-1>=0):
                    if(L[i-1][j]=='G'):
                        temp=1
                        break
                    elif(L[i-1][j]=='.'):
                        L[i-1][j]='#'
                if(i+1<n):
                    if(L[i+1][j]=='G'):
                        temp=1
                        break
                    elif(L[i+1][j]=='.'):
                        L[i+1][j]='#'

                if(j-1>=0):
                    if(L[i][j-1]=='G'):
                        temp=1
                        break
                    elif(L[i][j-1]=='.'):
                        L[i][j-1]='#'

                if(j+1<m):
                    if(L[i][j+1]=='G'):
                        temp=1
                        break
                    elif(L[i][j+1]=='.'):
                        L[i][j+1]='#'
        if(temp==1):
            break

    if(temp==1 or (L[n-1][m-1]=='#' and org>0)):
        print('No')
    else:
        global ct
        ct=0
        
        def dfs(i,j):
            if(L[i][j]=='G'):
                global ct
                ct+=1
            if(i-1>=0):
                if(L[i-1][j]!='#' and vis[i-1][j]==False):
                    vis[i-1][j]=True
                    dfs(i-1,j)
                    
            if(i+1<n):
                if(L[i+1][j]!='#' and vis[i+1][j]==False):
                    vis[i+1][j]=True
                    dfs(i+1,j)

            if(j-1>=0):
                if(L[i][j-1]!='#' and vis[i][j-1]==False):
                    vis[i][j-1]=True
                    dfs(i,j-1)


            if(j+1<m):
                if(L[i][j+1]!='#' and vis[i][j+1]==False):
                    vis[i][j+1]=True
                    dfs(i,j+1)

                    
                    
        vis[n-1][m-1]=True
        dfs(n-1,m-1)


        if(ct==org):
            print('Yes')
        else:
            print('No')

        
                        
                    
