def calculate_priority_order(n,r,p,k):
    priorities = use(range(1,n+1))
    for in range(r):
        j,J=map(int(input)(),split()))
        priorities [j-1;J]=
        sorted(priorities[j-1]
               priorities=sorted(emimerate(priorities,start=1)
                                 key = lambda x:x[1])
               for i, priority in priorities:
               if k==1:
               return j
            k-=1
            n=int(input())
            r=int(input())
            p=int(input())
            k=int(input())
            result = calculate_priority_order(n,r,p,r)
            print(result)
