for _ in range(int(input())):
    def solve():
        n,m=(map(int,input().split()))
        a=[]
        
        mat=[[0 for i in range(m)] for j in range(n)]
        good=0
        for i in range(n):
            a.append(input())
            if 1:
                good+=a[-1].count("G")
        
        if good==0:
            return "Yes"
        if m-2>=0 and a[n-1][m-2]=="B":
            return "No"
        if n-2>=0 and a[n-2][m-1]=="B":
            return "No"    
        if 1:
            for i in range(n):
                for j in range(m):
                    st=[]
                    if a[i][j] in "#":
                        mat[i][j]=1
                    if mat[i][j]==0:
                        if a[i][j]=="B":
                            st.append((i,j))
                        while st:
                            
                            x,y=st.pop(0)
                            # print(x,y,mat)
                            if x+1<n and a[x+1][y]=="G":
                                return "No"
                            if x+1<n  and a[x+1][y] in ".":
                                mat[x+1][y]=1
                            if x+1<n and  a[x+1][y]=="B" and mat[x+1][y]==0:
                                st.append((x+1,y))
                                mat[i][j]=1
                            if x-1>=0  and a[x-1][y]=="G":
                                return "No"
                            if x-1>=0  and a[x-1][y] in ".":
                                mat[x-1][y]=1
                            if x-1>=0  and a[x-1][y]=="B" and mat[x-1][y]==0:
                                st.append((x-1,y))
                                mat[x-1][y]=1
                                
                            if y+1<m  and a[x][y+1]=="G":
                                return "No"
                            if y+1<m  and a[x][y+1] in ".":
                                mat[x][y+1]=1
                            if y+1<m  and a[x][y+1]=="B" and mat[x][y+1]==0:
                                st.append((x,y+1))
                                mat[x][y+1]=1
                                
                            if y-1>=0  and a[x][y-1]=="G":
                                return "No"
                            if y-1>=0  and a[x][y-1] in ".":
                                mat[x][y-1]=1
                            if y-1>=0  and a[x][y-1]=="B" and mat[x][y-1]==0:
                                st.append((x,y-1))
                                mat[x][y-1]=1
                                
        
        st=[(n-1,m-1)]
        mat[n-1][m-1]=1
        while st:
            x,y=st.pop(0)
            if a[x][y]=="G":
                good-=1
            # print(x,y,mat)
            if x+1<n and mat[x+1][y]==0:
                st.append((x+1,y))
                mat[x+1][y]=1
            
            if x-1>=0  and mat[x-1][y]==0:
                st.append((x-1,y))
                mat[x-1][y]=1
                
            if y+1<m  and mat[x][y+1]==0:
                st.append((x,y+1))
                mat[x][y+1]=1
                
            if y-1>=0  and mat[x][y-1]==0:
                st.append((x,y-1))
                mat[x][y-1]=1
        
        if good==0:
            return "Yes"
        else:
            return "No"

                
            
            
            
    print(solve())            
    # solve()                            
                                