for _ in range(int(input())):
    n,m=map(int,input().split())
    matx=[]
    for i in range(n):
        matx.append(list(input().strip()))
    d=[[-1,0],[0,-1],[0,1],[1,0]]
    an=1
    for i in range(n):
        for j in range(m):
            if matx[i][j]=='B':
                for p in range(4):

                    xx=i+d[p][0]
                    yy=j+d[p][1]
                    if 0<=xx<=n-1  and 0<=yy<=m-1 :
                        if matx[xx][yy]=='G' :
                            an=0
                            break
                        else:
                            matx[xx][yy]='#'
    #print(matx)
    p=0
    cnt = 0
    for i in matx:
        for j in i:
            if j == 'G':
                cnt += 1
    if an==1:
        vis=[[0]*m for i in range(n)]
        st=[(n-1,m-1)]
        if matx[n-1][m-1]=='#' or  matx[n-1][m-1]=='B' :
            an=0
        else:
            p=0
            while (st):
                xx=st[-1]
                st.pop()
                vis[xx[0]][xx[1]]=1
                if matx[xx[0]][xx[1]]== 'G':
                    p+=1
                for j in d:
                   pp,qq=xx[0]+j[0],xx[1]+j[1]
                   if 0 <= pp <= n - 1 and 0 <= qq<= m - 1 and not vis[pp][qq] and matx[pp][qq]!='#':
                       st.append((pp,qq))

    print('Yes' if an or p==cnt else 'No' )