for _ in range(int(input())):
    n,m=map(int,input().split())
    a=[list(input()) for _ in range(n)]
    c=0
    cg=0
    b=0
    for i in range(n):
        for j in range(m):
            if a[i][j]=='B':
                b+=1
                if i>0:
                    if a[i-1][j]=='G':
                        c=1
                        break
                    if a[i-1][j]!='B':
                        a[i-1][j]='#'
                if j>0:
                    if a[i][j-1]=='G':
                        c=1
                        break
                    if a[i][j-1]!='B':
                        a[i][j-1]='#'
                if i<n-1:
                    if a[i+1][j]=='G':
                        c=1
                        break
                    if a[i+1][j]!='B':
                        a[i+1][j]='#'
                if j<m-1:
                    if a[i][j+1]=='G':
                        c=1
                        break
                    if a[i][j+1]!='B':
                        a[i][j+1]='#'
            elif a[i][j]=='G':
                cg+=1
        if c==1:
            break
    if c==1:
        print('No')
    elif cg==0:
        print('Yes')
    elif a[n-1][m-1]=='#':
        print('No')
    else:
        cgg=0
        used=set()
        used.add((n-1,m-1))
        cur=[[n-1,m-1]]
        while cur!=[]:
            i,j=cur.pop(0)
            if a[i][j]=='G':
                cgg+=1
            if a[i][j]=='#':
                continue
            if i>0 and ((i-1,j) not in used):
                cur.append([i-1,j])
                used.add((i-1,j))
            if j>0 and ((i,j-1) not in used):
                cur.append([i,j-1])
                used.add((i,j-1))
            if i<n-1 and ((i+1,j) not in used):
                cur.append([i+1,j])
                used.add((i+1,j))
            if j<m-1 and ((i,j+1) not in used):
                cur.append([i,j+1])
                used.add((i,j+1))
        if cgg==cg:
            print('Yes')
        else:
            print('No')