import sys
read=input
#sys.stdin.buffer.readline
mi=lambda :map(int,read().split())
cin=lambda :int(read())
li=lambda:list(mi())


for _ in range(cin()):
    n,m=mi()
    a=[]
    nz=0
    for i in range(n):
        a.append(list(input()))
        for el in a[-1]:
            if el=='G':
                nz+=1
    if a[-1][-1]=='B':
        print('No')
        continue
    def isnb(a,i,j,m,n):
        if i+1<n and a[i+1][j]=='B':
            return True
        if i-1>=0 and a[i-1][j]=='B':
            return True
        if j+1<m and a[i][j+1]=='B':
            return True
        if j-1>=0 and a[i][j-1]=='B':
            return True
        return False
    vz=0
    vis=[[0 for i in range(m)] for j in range(n)]
    st=[[n-1,m-1]]
    vis[n-1][m-1]=1
    while st:
        i,j=st[-1][0],st[-1][1]
        st.pop()
        if isnb(a,i,j,m,n):
            continue
        if a[i][j]=='G':
            vz+=1
        if i+1<n and vis[i+1][j]==0 and a[i+1][j]!='#':
            st.append([i+1,j])
            vis[i+1][j]=1
        if j+1<m and vis[i][j+1]==0 and a[i][j+1]!='#':
            st.append([i,j+1])
            vis[i][j+1]=1
        if i-1>=0 and vis[i-1][j]==0 and a[i-1][j]!='#':
            st.append([i-1,j])
            vis[i-1][j]=1
        if j-1>=0 and vis[i][j-1]==0 and a[i][j-1]!='#':
            st.append([i,j-1])
            vis[i][j-1]=1
    if nz!=vz:
        print('No')
    else:
        print('Yes')