import sys input = sys.stdin.readline from operator import itemgetter N,Q,WT,ST=map(int,input().split()) W=list(map(int,input().split())) LR=[list(map(int,input().split()))+[i+1] for i in range(Q)] LR.sort(key=itemgetter(0)) LIST=[[] for i in range(1000)] for x,y,ind in LR: LIST[x//500].append((y,ind)) ANS=[] count=0 for i in range(1000): if LIST[i]==[]: continue if count%2==0: LIST[i].sort(key=itemgetter(0)) else: LIST[i].sort(key=itemgetter(0),reverse=True) for _,ind in LIST[i]: ANS.append(ind) count+=1 print(*ANS)