#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
ll fw[N],d[N],c[N],ret[N];
vector<pair<ll,int>> qr[N];
void upd(int i,ll val){for(;i<N;i+=i&-i) fw[i]+=val;}
ll qry(int i){ll s=0; for(;i;i-=i&-i) s+=fw[i]; return s;}
int fd(ll x){
if(qry(N-1)<x) return -1;
int now=0,sum=0;
for(int i=20;i>=0;i--){
if(now+(1<<i)<N && sum+fw[now+(1<<i)]<x){
sum+=fw[now+(1<<i)];
now+=(1<<i);
}
}
return now;
}
int main(){
stack<int> st;
int n,q; cin>>n >>q;
for(int i=1;i<=n;i++) cin>>d[i] >>c[i];
for(int i=0;i<q;i++){
int s; ll vol;
cin>>s >>vol;
qr[s].push_back({vol,i});
}
for(int i=n;i>=1;i--){
while(!st.empty() && d[st.top()]<=d[i]) upd(st.top(),-c[st.top()]),st.pop();
st.push(i);
upd(i,c[i]);
for(auto [vol,ind]:qr[i]){
ret[ind]=fd(vol)+1;
}
}
for(int i=0;i<q;i++) cout<<ret[i] <<"\n";
}