import itertools as it
def main():
    for _ in range(int(input())):
        n,m=map(int,input().split())
        l=[list(input()) for i in range(n)]
        alpha=list(it.chain.from_iterable(l))
        # print(alpha)
        b,f,g=[],0,0
        for i in range(n):
            for j in range(m):
                if(l[i][j]=='B'):
                    b.append((i,j))
                    if(i-1>=0 and l[i-1][j]=='G'):
                        f=1
                    if(i+1<=n-1 and l[i+1][j]=='G'):
                        f=1
                    if(j-1>=0 and l[i][j-1]=='G'):
                        f=1
                    if(j+1<=m-1 and l[i][j+1]=='G'):
                        f=1
                    if(i-1>=0 and l[i-1][j]=='.'):
                        l[i-1][j]='#'
                    if(i+1<=n-1 and l[i+1][j]=='.'):
                        l[i+1][j]='#'
                    if(j-1>=0 and l[i][j-1]=='.'):
                        l[i][j-1]='#'
                    if(j+1<=m-1 and l[i][j+1]=='.'):
                        l[i][j+1]='#'
        chk=set()
        for i in range(n):
            for j in range(m):
                if(l[i][j]=='G'):
                    g=0
                    if(i-1>=0 and (l[i-1][j]=='.' or (l[i-1][j]=='G' and (i-1,j) not in chk)) ):
                        g=1
                    if(i+1<=n-1 and (l[i+1][j]=='.' or (l[i+1][j]=='G' and (i+1,j) not in chk))):
                        g=1
                    if(j-1>=0 and (l[i][j-1]=='.' or (l[i][j-1]=='G' and (i,j-1) not in chk))):
                        g=1
                    if(j+1<=m-1 and (l[i][j+1]=='.' or (l[i][j+1]=='G' and (i,j+1) not in chk))):
                        g=1
                    if(g!=1):
                        break
                    chk.add((i,j))
        if((g==1 or alpha.count('G')==0 ) and f==0 and (l[n-1][m-1]=='#' and alpha.count('G')==0)):
            print('Yes')
        elif((g==1 or alpha.count('G')==0 ) and f==0 and (l[n-1][m-1]=='.')):
            print('Yes')
        else:
            print('No')
main()