t = int(input())


while t:
    t-=1
    n,m = map(int,input().split())


    def ck(x, y):

        return x >= 0 and y >= 0 and x < n and y < m
    maze = [[0] for y in range(n)]


    tx = [0, 0, -1, 1]
    ty = [1, -1, 0, 0]

    Bad = []
    for i in range(n):
        maze[i] = list(input())
    end = False
    for i in range(n):
        for j in range(m):
            if maze[i][j]=='B':
                for k in range(4):
                    x = i + tx[k]
                    y = j+ ty[k]
                    if ck(x,y):
                        if maze[x][y]=='.':
                            maze[x][y] = '#'
                        if maze[x][y]=='G':
                            end = True
                            break
            if end:
                break
        if end:
            break

    if end:
        print('No')
        continue
    q = []
    vis = [[0 for x in range(m)] for y in range(n)]
    #print(vis)
    if maze[n-1][m-1] != '#':
        vis[n-1][m-1] = 1
        q.append([n-1,m-1])

    #print(maze)
    while q:

        tem = q.pop(0)

        x = tem[0]
        y = tem[1]
        for i in range(4):
            if ck(x+tx[i],y+ty[i]):

                if maze[x+tx[i]][y+ty[i]] !='#' and vis[x+tx[i]][y+ty[i]]==0:
                    vis[x+tx[i]][y+ty[i]] = 1
                    q.append([x+tx[i],y+ty[i]])
    ok = True
    for i in range(n):
        for y in range(m):
            if maze[i][y]=='G' and vis[i][y]==0:
                end=True
                break
        if end:
            break
    if end:
        print('No')
    else:
        print('Yes')