T = int(input().strip())
for t in range(T):
    n, k  = list(map(int, input().split()))
    s = []
    for i in range(n):
        a, b = list(map(int, input().split()))
        s.append(((a,b, i+1)))
    s = sorted(s, key=lambda x:x[0])
    army = sorted(s[-k:], key=lambda x:x[1])
    res = []
    for i in range(k - 1):
        res.append(army[i][2])
    for i in range(n-k):
        res.append(s[i][2])
        res.append(-s[i][2])
    res.append(army[k-1][2])
    print(len(res))
    print(*res)




