#include <bits/stdc++.h>
using namespace std;
vector<int> x;
struct qe {
  int no;
  int x, y;
  qe(int nn, int xx, int yy) { no = nn, x = xx, y = yy; }
};
bool cmp(const qe& a, const qe& b) { return a.x > b.x; }
vector<qe> qs;
long long sg[10000000];
int lz[10000000];
int sl[10000000];
int sr[10000000];
long long a[210000];
long long b[210000];
int o[210000];
int cu = 2;
int up(long long x, long long y, int n, long long b, long long e) {
  if (y < b || e < x) return sg[n];
  if (x <= b && e <= y) {
    sg[n] = 1 * (e - b + 1);
    lz[n] = 1;
    return sg[n];
  }
  if (lz[n] == 1) return sg[n];
  sg[n] = 0;
  long long md = ((long long)b + (long long)e) / 2;
  if (x <= md || sl[n] != -1) {
    if (sl[n] == -1) sl[n] = cu++;
    sg[n] += up(x, y, sl[n], b, md);
  }
  if (y >= md + 1 || sr[n] != -1) {
    if (sr[n] == -1) sr[n] = cu++;
    sg[n] += up(x, y, sr[n], md + 1, e);
  }
  return sg[n];
}
int vl(long long x, long long y, int n, long long b, long long e) {
  if (x <= b && e <= y) return sg[n];
  if (y < b || e < x) return 0;
  if (lz[n] == 1) {
    return min(y, e) - max(x, b) + 1;
  }
  int re = 0;
  long long md = ((long long)b + (long long)e) / 2;
  if (sl[n] != -1) re += vl(x, y, sl[n], b, md);
  if (sr[n] != -1) re += vl(x, y, sr[n], md + 1, e);
  return re;
}
int main() {
  int n, m, c, d, q;
  scanf("%d", &n);
  for (int i = 0; i <= 9000000; i++) sg[i] = 0, sl[i] = -1, sr[i] = -1;
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &a[i], &b[i]);
    b[i] = min(b[i] + a[i], 1000001000LL);
    x.push_back(i);
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &c, &d);
    qs.push_back(qe(i, c, d));
  }
  sort(qs.begin(), qs.end(), cmp);
  int clx;
  int an;
  for (int i = 0; i < qs.size(); i++) {
    clx = qs[i].x;
    while (x.size() != 0 && clx <= x.back()) {
      up(a[x.back()] + 1, b[x.back()], 1, 0, 1000000100LL);
      x.pop_back();
    }
    an = a[qs[i].y] - a[qs[i].x] -
         vl(a[qs[i].x] + 1, a[qs[i].y], 1, 0, 1000000100LL);
    o[qs[i].no] = an;
  }
  for (int i = 1; i <= q; i++) printf("%d\n", o[i]);
}
