#include <bits/stdc++.h>
using namespace std;
const int N = 200008;
int n, m, L[N], R[N], top, q[N], ans[N], fa[N], sum[N], maxr[N];
struct Query {
  int s, t, p;
  bool operator<(const Query &b) const { return s < b.s; }
} Q[N];
int find(int x) { return x == fa[x] ? fa[x] : fa[x] = find(fa[x]); }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &L[i], &R[i]), R[i] += L[i], fa[i] = i, maxr[i] = R[i];
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d%d", &Q[i].s, &Q[i].t), Q[i].p = i;
  sort(Q + 1, Q + m + 1);
  int pos = m;
  for (int i = n; i >= 1; i--) {
    int l = L[i], r = R[i];
    while (top && r >= L[q[top]]) {
      maxr[i] = max(r, maxr[find(q[top])]);
      fa[find(q[top])] = i;
      top--;
    }
    if (i < n) sum[i] = sum[q[top]] + L[q[top]] - maxr[i];
    q[++top] = i;
    while (pos && Q[pos].s == i)
      ans[Q[pos].p] = sum[i] - sum[find(Q[pos].t)], pos--;
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
