from sys import stdin,stdout
from collections import deque
def main():
    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 i in range(n):
            for j in range(m):
                if a[i][j] == 'B':
                    if i!=0:
                        if a[i-1][j]=='.':
                            a[i-1][j]='#'
                    if i!=n-1:
                        if a[i+1][j]=='.':
                            a[i+1][j]='#'
                    if j!=0:
                        if a[i][j-1]=='.':
                            a[i][j-1]='#'
                    if j!=m-1:
                        if a[i][j+1]=='.':
                            a[i][j+1]='#'
                elif a[i][j]=="G":
                    g.append((i,j))
        z=len(g)
        if z==n*m-1 or z==0:
            stdout.write("Yes\n")
            continue
        path= set()
        ans="No"
        for i in g:
            ans = "No"
            visited= set()
            visited.add(i)
            q=deque()
            q.appendleft(i)
            while q:
                b=q.pop()
                if b not in path:
                    path.add(b)
                else:
                    ans = "Yes"
                    break
                u=b[0]
                v=b[1]
                if u==n-1 and v==m-1:
                    ans="Yes"
                    break
                if u!=0:
                    if (u-1,v) not in visited:
                        if a[u-1][v]=='.' or a[u-1][v]=='G':
                            q.appendleft((u-1,v))
                            visited.add((u-1,v))
                        elif a[u-1][v]=='B':
                            break
                if u!=n-1:
                    if (u+1,v) not in visited:
                        if a[u+1][v]=='.' or a[u+1][v]=='G':
                            q.appendleft((u+1,v))
                            visited.add((u+1,v))
                        elif a[u+1][v]=='B':
                            break
                if v!=0:
                    if (u,v-1) not in visited:
                        if a[u][v-1]=='.' or a[u][v-1]=='G':
                            q.appendleft((u,v-1))
                            visited.add((u,v-1))
                        elif a[u][v-1]=='B':
                            break
                if v!=m-1:
                    if (u,v+1) not in visited:
                        if a[u][v+1]=='.' or a[u][v+1]=='G':
                            q.appendleft((u,v+1))
                            visited.add((u,v+1))
                        elif a[u][v+1]=='B':
                            break
            if ans!="Yes":
                break
        stdout.write(ans+"\n")
if __name__=="__main__":
    main()