from sys import  stdin, stdout
from math import *
from heapq import *
from collections import *
a=[]
def main():
    ntest=int(stdin.readline())
    for testcase in range(ntest):
        n,m=[int(k) for k in stdin.readline().split()]
        a=[]
        for i in range(n+2):
            if (i<=0) or (i>n):
                a.append(['#']*(m+2))
            else:
                a.append(list('#'+stdin.readline().strip()+'#'))
        succ=True
        goodp=0
        for i in range(1,1+n):
            for j in range(1,1+m):
                if a[i][j]=='G':
                    goodp+=1
                if a[i][j]=='B':
                    for r,c in [[i-1,j],[i,j-1],[i+1,j],[i,j+1]]:
                        if a[r][c]=='B':
                            continue
                        if a[r][c]=='G':
                            succ=False
                            continue
                        if a[r][c]=='.':
                            if (r==n) and (c==m):
                                succ=False
                            a[r][c]='#'
        if (goodp==0):
            stdout.write("Yes\n")
            continue
        q=[(n,m)]
        resc=0
        i=0
        while (i<len(q)):
            r,c=q[i]
            for u,v in [(r-1,c),(r,c-1),(r+1,c),(r,c+1)]:
                if (a[u][v] == 'G'):
                    resc+=1
                if (a[u][v] != '#'):
                    a[u][v]='#'
                    q.append((u,v))
            i+=1
        
        if (succ) and resc>=goodp:
            stdout.write("Yes\n")
        else:
            stdout.write("No\n")
    return 0

if __name__ == "__main__":
    main()