#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int N, Q;
long long D[MAXN], C[MAXN];
int nextGreater[MAXN];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> Q;
for (int i = 1; i <= N; i++)
cin >> D[i] >> C[i];
// Next Greater Diameter
stack<int> st;
for (int i = N; i >= 1; i--) {
while (!st.empty() && D[st.top()] <= D[i])
st.pop();
nextGreater[i] = st.empty() ? 0 : st.top();
st.push(i);
}
// Queries
while (Q--) {
int R;
long long V;
cin >> R >> V;
int cur = R;
while (cur != 0 && V > 0) {
long long take = min(V, C[cur]);
V -= take;
if (V > 0)
cur = nextGreater[cur];
else
break;
}
cout << cur << "\n";
}
return 0;
}