R=[-1,1,0,0];C=[0,0,-1,1]
def bfs(mat,x):
    visited=[[False]*m for i in range(n)]
    visited[x[0]][x[1]]=True
    st=[x]
    while(len(st)>0):
        v=st.pop()
        if(v==(n-1,m-1)):
            return True
        for i in range(4):
            r=v[0]+R[i]
            c=v[1]+C[i]
            if(0<=r<n and 0<=c<m and mat[r][c]==0 and not visited[r][c]):
                visited[r][c]=True
                st.append((r,c))
    return False
def chk(mat,a):
    if(len(a)==0):
        return True
    for i in a:
        if(not bfs(mat,i)):
            return False
    return True
def find():
    a=good.keys()
    for i in range(n):
        for j in range(m):
            if((i,j) in good or (i,j) in bad):
                continue
            mat[i][j]=1
            if(not chk(mat,a)):
                mat[i][j]=0
            
for _ in range(int(input())):
    n,m=map(int,input().split())
    a=[input() for i in range(n)]
    mat=[[0]*m for i in range(n)]
    good={};bad={}
    for i in range(n):
        for j in range(m):
            if(a[i][j]=='.'):
                mat[i][j]=0
            elif(a[i][j]=='#'):
                mat[i][j]=1
            else:
                if(a[i][j]=='G'):
                    good[(i,j)]=1
                else:
                    bad[(i,j)]=1
                mat[i][j]=0
    find()
    ans="No" if(chk(mat,bad.keys())) else "Yes"
    if(len(bad.keys())==0)or len(good.keys())==0:
        ans='Yes'
    if((n-1,m-1) in bad.keys()):
        ans='No'
    print(ans)
