from sys import stdin,stdout
from collections import deque
def bfs(a,i,n,m):
    global flag
    global final
    global visited
    q=deque()
    q.appendleft(i)
    while q:
        b=q.pop()
        u=b[0]
        v=b[1]
        if (u*m+v) in visited:
            continue
        else:
            visited.add(u*m+v)
        if u==n-1 and v==m-1:
            final=1
            break
        if u!=n-1:
            if a[u+1][v]=='.' or a[u+1][v]=='G':
                q.appendleft([u+1,v])
            elif a[u+1][v]=="B":
                flag=1
                break
        if u!=0:
            if a[u-1][v]=='.' or a[u-1][v]=='G':
                q.appendleft([u-1,v])
            elif a[u-1][v]=='B':
                flag=1
                break
        if v!=0:
            if a[u][v-1]=='.' or a[u][v-1]=='G':
                q.appendleft([u,v-1])
            elif a[u][v-1]=='B':
                flag=1
                break
        if v!=m-1:
            if a[u][v+1]=='.' or a[u][v+1]=='G':
                q.appendleft([u,v+1])
            elif a[u][v+1]=='B':
                flag=1
                break
def main():
    global flag
    global final
    global visited
    for t in range(int(stdin.readline())):
        n,m=map(int,stdin.readline().split())
        a=[]
        g=[]
        for i in range(n):
            a.append(list(stdin.readline().strip()))
            for j in range(m):
                if a[i][j]=="G":
                    g.append([i,j])
        #print(g)
        for i in range(n):
            if m==1:
                if a[i][0]=='B':
                    if i!=n-1:
                        if a[i+1][0]=='.':
                            a[i+1][0]='#'
                    else:
                        if a[i-1][0]=='.':
                            a[i-1][0]='#'
            else:
                for j in range(m):
                    if a[i][j]=="B":
                        if n==1:
                            if j!=m-1:
                                if a[i][j+1]=='.':
                                    a[i][j+1]='#'
                            else:
                                if a[i][j-1]=='.':
                                    a[i][j-1]='#'
                        else:
                            if i==0:
                                if j==0:
                                    if a[i][j+1]=='.':
                                        a[i][j+1]='#'
                                    if a[i+1][j]=='.':
                                        a[i+1][j]='#'
                                elif j==m-1:
                                    if a[i][j-1]=='.':
                                        a[i][j-1]='#'
                                    if a[i+1][j]=='.':
                                        a[i+1][j]='#'
                                else:
                                    if a[i][j+1]=='.':
                                        a[i][j+1]='#'
                                    if a[i][j - 1] == '.':
                                        a[i][j-1]='#'
                                    if a[i+1][j] == '.':
                                        a[i+1][j]='#'
                            elif i==n-1:
                                if j==0:
                                    if a[i][j+1]=='.':
                                        a[i][j+1]='#'
                                    if a[i-1][j]=='.':
                                        a[i-1][j]='#'
                                elif j==m-1:
                                    if a[i][j-1]=='.':
                                        a[i][j-1]='#'
                                    if a[i-1][j]=='.':
                                        a[i-1][j]='#'
                                else:
                                    if a[i][j+1]=='.':
                                        a[i][j+1]='#'
                                    if a[i][j - 1] == '.':
                                        a[i][j-1]='#'
                                    if a[i-1][j] == '.':
                                        a[i-1][j]='#'
                            else:
                                if j==0:
                                    if a[i-1][j]=='.':
                                        a[i-1][j]='#'
                                    if a[i+1][j]=='.':
                                        a[i+1][j]='#'
                                    if a[i][j+1]=='.':
                                        a[i][j+1]='#'
                                elif j==m-1:
                                    if a[i-1][j]=='.':
                                        a[i-1][j]='#'
                                    if a[i+1][j]=='.':
                                        a[i+1][j]='#'
                                    if a[i][j-1]=='.':
                                        a[i][j-1]='#'
                                else:
                                    if a[i-1][j]=='.':
                                        a[i-1][j]='#'
                                    if a[i+1][j]=='.':
                                        a[i+1][j]='#'
                                    if a[i][j-1]=='.':
                                        a[i][j-1]='#'
                                    if a[i][j+1]=='.':
                                        a[i][j+1]='#'
        z=len(g)
        #print(g)
        #print(a)
        if z==n*m-1 or z==0:
            stdout.write("Yes\n")
            continue
        ans="Yes"
        visited = set()
        for i in g:
            flag=0
            final=0
            bfs(a,i,n,m)
            if flag==1 or final==0:
                ans="No"
                break
        stdout.write(ans+"\n")
if __name__=="__main__":
    main()