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(1)) LR.sort(key=itemgetter(0)) ANS=[LR[i][2] for i in range(Q)] print(*ANS)