for _ in range(int(input())):
    n,k=map(int,input().split())
    arr=[]
    for i in range(n):
        a,b=map(int,input().split())
        arr.append([a,b,i+1])
    arr.sort(key=lambda x:x[1])
    if(k==1):
        arr.sort(key=lambda x:x[0],reverse=True)
        print(1)
        print(arr[0][2])
        continue
    print(k+(n-k)*2)
    for i in range(k-1):
        print(arr[i][2],end=" ")
    for i in range(k-1,n-1):
        print(arr[i][2],-arr[i][2],end=" ")
    print(arr[n-1][2])
    