#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
const int maxn = 200010;
int N, Q;
int pos[maxn], len[maxn];
int ans[maxn];
struct Qu {
  int x, y, id;
  bool operator<(const Qu &a) const { return x > a.x; }
} q[maxn];
struct IntervalTree {
  int setv[maxn << 2];
  int sum[maxn << 2];
  void build(int o, int l, int r) {
    setv[o] = 0;
    sum[o] = INF;
    if (l == r) return;
    int mid = (l + r) >> 1;
    build(o << 1, l, mid);
    build(o << 1 | 1, mid + 1, r);
  }
  void pushdown(int o) {
    if (setv[o]) {
      setv[o << 1] = setv[o << 1 | 1] = 1;
      sum[o << 1] = sum[o << 1 | 1] = 0;
      setv[o] = 0;
    }
  }
  void pushup(int o) { sum[o] = sum[o << 1] + sum[o << 1 | 1]; }
  void update1(int o, int l, int r, int q1, int q2) {
    if (q1 <= l && r <= q2) {
      sum[o] = 0;
      setv[o] = 1;
      return;
    }
    pushdown(o);
    int mid = (l + r) >> 1;
    if (q1 <= mid) update1(o << 1, l, mid, q1, q2);
    if (q2 > mid) update1(o << 1 | 1, mid + 1, r, q1, q2);
    pushup(o);
  }
  void update2(int o, int l, int r, int x, int val) {
    if (l == r) {
      sum[o] = min(sum[o], val);
      return;
    }
    pushdown(o);
    int mid = (l + r) >> 1;
    if (x <= mid)
      update2(o << 1, l, mid, x, val);
    else
      update2(o << 1 | 1, mid + 1, r, x, val);
    pushup(o);
  }
  int query(int o, int l, int r, int q1, int q2) {
    if (q1 <= l && r <= q2) return sum[o];
    int res = 0;
    pushdown(o);
    int mid = (l + r) >> 1;
    if (q1 <= mid) res += query(o << 1, l, mid, q1, q2);
    if (q2 > mid) res += query(o << 1 | 1, mid + 1, r, q1, q2);
    pushup(o);
    return res;
  }
} tree;
void solve() {
  tree.build(1, 1, N);
  int cur = 1;
  for (int i = N - 1; i > 0; i--) {
    int l = lower_bound(pos + 1, pos + N + 1, pos[i] + len[i]) - pos;
    if (l - 1 >= i + 1) tree.update1(1, 1, N, i + 1, l - 1);
    if (l <= N) tree.update2(1, 1, N, l, pos[l] - pos[i] - len[i]);
    while (cur <= Q && q[cur].x == i) {
      ans[q[cur].id] = tree.query(1, 1, N, q[cur].x + 1, q[cur].y);
      cur++;
    }
  }
  for (int i = 1; i <= Q; i++) printf("%d\n", ans[i]);
}
int main() {
  while (scanf("%d", &N) != EOF) {
    for (int i = 1; i <= N; i++) scanf("%d%d", &pos[i], &len[i]);
    scanf("%d", &Q);
    for (int i = 1; i <= Q; i++) {
      scanf("%d%d", &q[i].x, &q[i].y);
      q[i].id = i;
    }
    sort(q + 1, q + 1 + Q);
    solve();
  }
  return 0;
}
