#include using namespace std; int main() { long long n,A,t,a,b; cin >> n >> A; vectoriti(n); for(int i=0;i> iti[i]; vector>start; vector>goal; cin >> t; for(int q=0;q> a >> b; start.push_back(make_pair(a,q+1)); goal.push_back(make_pair(b+1,q+1)); } int x=0,y=0; sort(start.begin(),start.end()); sort(goal.begin(),goal.end()); setst; priority_queueprq; for(int i=0;i0 && st.count(prq.top())>0)prq.pop(); if(prq.size()==0)cout << -1 << endl; else cout << prq.top() << endl; } return 0; }