T=int(input())
for t in range(T):
    n,k=map(int,input().split())
    dict=[]
    for i in range(n):
        temp=list(map(int,input().split()))
        dict.append((i+1,temp[0],temp[1]))
    lst=sorted(dict,key=lambda var:var[1],reverse=True)
    dict=sorted(dict,key=lambda var:var[2],reverse=True)
    if k==1:
        print(1)
        print(lst[0][0])
    elif k==n:
        print(n)
        temp=[str(var[0]) for var in lst]
        print(" ".join(temp))
    else:
        moves=[]
        i=1
        moves.append(str(lst[0][0]))
        lst.remove(lst[0])
        while i<k:
            moves.append(str(dict[0][0]))
            dict.remove(dict[0])
            i+=1
        moves.append("-{}".format(moves[-1]))
        moves.append(str(dict[0][0]))
        print(len(moves))
        print(" ".join(moves))
