#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int d[maxn], c[maxn], nexts[maxn];
struct edge {
int to, next;
} e[maxn];
int cnt = 1;
int head[maxn];
void add(int u, int v) {
e[cnt].to = v;
e[cnt].next = head[u];
head[u] = cnt++;
}
int deep[maxn];
int ance[maxn][21];
int tale[maxn][21];
void dfs(int now, int fa) {
ance[now][0] = fa;
tale[now][0] = c[fa];
deep[now] = deep[fa] + 1;
for (int i = 1; (1<<i)<=deep[now]; i++) {
ance[now][i] = ance[ance[now][i - 1]][i - 1];
tale[now][i] = tale[ance[now][i - 1]][i - 1] + tale[now][i - 1];
}
for (int i = head[now]; i; i = e[i].next) {
int tx = e[i].to;
if (tx == fa) continue;
dfs(tx, now);
}
}
int main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> d[i] >> c[i];
}
stack<int> s;
s.push(1);
d[n+1] = INT_MAX;
c[n+1] = INT_MAX;
for (int i = 2; i <= n+1; i++) {
while (!s.empty() && d[s.top()] < d[i]) {
nexts[s.top()] = i;
s.pop();
}
s.push(i);
}
for (int i = 1; i <= n; i++) {
add(nexts[i], i);
}
dfs(n + 1, 0);
for (int i = 1; i <= m; i++) {
int r, v;
cin >> r >> v;
if (c[r] >= v) {
cout << r << "\n";
continue;
}
v-=c[r];
int x = r;
int ans = 0;
for (int j = 20; j >= 0; j--) {
if (deep[x] >= (1 << j) && tale[x][j] <= v) {
v -= tale[x][j];
x = ance[x][j];
}
if (v == 0) {
ans = x;
}
}
if (ans == 0)
ans = ance[r][0];
if (ans == n + 1)
ans = 0;
if (ans==0) ans=ance[x][0];
if (ans==n+1) cout<<0<<endl;else cout<<ans<<endl;
}
return 0;
}