#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2e5;
int n, m, L, R;
long long sum[MaxN + 5];
struct domino {
  long long l, x;
} a[MaxN + 5];
struct EDGE {
  long long l, r;
} seq[MaxN + 5];
struct Que {
  int l, r, p;
  long long ans;
} q[MaxN + 5];
bool cmp1(Que a, Que b) { return a.l > b.l; }
bool cmp2(Que a, Que b) { return a.p < b.p; }
void Push_In(int p) {
  EDGE H;
  H.l = a[p].x;
  H.r = a[p].l + a[p].x;
  while (R >= L && seq[R].l <= H.r) {
    H.r = max(H.r, seq[R].r);
    R--;
  }
  seq[++R] = H;
  if (R == 1)
    sum[R] = 0;
  else
    sum[R] = sum[R - 1] + seq[R - 1].l - seq[R].r;
}
int Solve(long long x) {
  int l = 1, r = R, mid, ans;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (seq[mid].l <= x)
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &a[i].x, &a[i].l);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d%d", &q[i].l, &q[i].r), q[i].p = i;
  sort(q + 1, q + m + 1, cmp1);
  int l = n;
  L = 1;
  R = 0;
  Push_In(l);
  for (int i = 1; i <= m; i++) {
    while (q[i].l < l) Push_In(--l);
    int pp = Solve(a[q[i].r].x);
    q[i].ans = sum[R] - sum[pp];
  }
  sort(q + 1, q + m + 1, cmp2);
  for (int i = 1; i <= m; i++) printf("%lld\n", q[i].ans);
}
