for _ in range(int(input())):
    n, m = list(map(int,input().split()))
    arr = []
    nArr = []
    for i in range(n):
        arr.append(list(input()))
    for i in range(n):
        strQ = []
        for g in range(m):
            strQ.append(arr[i][g])
        nArr.append(strQ)
    fl = True

    for i in range(n):
        for g in range(m):
            if arr[i][g] == "B":
                if arr[max(i-1,0)][g] == "G" or arr[min(i+1,n-1)][g] == "G" or arr[i][min(g+1,m-1)] == "G" or arr[i][max(g-1,0)] == "G":
                    fl = False
                    break
                else:
                    nArr[max(i-1,0)][g] = "#"
                    nArr[min(i+1,n-1)][g] = "#"
                    nArr[i][min(g+1,m-1)] = "#"
                    nArr[i][max(g-1,0)] = "#"
        else:
            continue
        break
    if fl:
        arr = nArr
        g = 0
        for i in range(n):
            g+=arr[i].count("G")
        if g and arr[n-1][m-1] == "#":
            print("No")
            continue
        if not g:
            print("Yes")
            continue
        was = []
        for i in range(n):
            was.append([False]*m)
        #
        def fillPath(x,y):
            if not was[y][x]:
                was[y][x] = True
                if not was[max(y - 1, 0)][x] and arr[max(y - 1, 0)][x] != "#":
                    fillPath(x,max(y - 1, 0))
                if not was[min(y + 1, n - 1)][x] and arr[min(y + 1, n - 1)][x] != "#":
                    fillPath(x,min(y + 1, n - 1))
                if not was[y][min(x+1,m-1)] and arr[y][min(x+1,m-1)] != "#":
                    fillPath(min(x+1,m-1),y)
                if not was[y][max(x-1,0)] and arr[y][max(x-1,0)] != "#":
                    fillPath(max(x-1,0),y)
        fillPath(m-1,n-1)

        for i in range(n):
            for g in range(m):
                if arr[i][g] == "G" and not was[i][g]:
                    print("No")
                    break
            else:
                continue
            break
        else:
            print("Yes")
    else:
        print("No")

