#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int N, Q;
long long D[MAXN], C[MAXN];
long long water[MAXN];
int nextGreater[MAXN];
int parent[MAXN];
int find_set(int v) {
if (parent[v] == v) return v;
return parent[v] = find_set(parent[v]);
}
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];
parent[i] = i;
}
// -------- 1. Next Greater Diameter --------
stack<int> st;
for (int i = N; i >= 1; i--) {
while (!st.empty() && D[st.top()] <= D[i])
st.pop();
if (st.empty()) nextGreater[i] = 0;
else nextGreater[i] = st.top();
st.push(i);
}
// -------- 2. Queries --------
while (Q--) {
int R;
long long V;
cin >> R >> V;
int cur = find_set(R);
while (cur != 0 && V > 0) {
long long canFill = min(V, C[cur] - water[cur]);
water[cur] += canFill;
V -= canFill;
if (water[cur] == C[cur]) {
parent[cur] = find_set(nextGreater[cur]);
}
cur = find_set(cur);
}
cout << cur << "\n";
}
return 0;
}