#include <bits/stdc++.h>
using namespace std;
struct node;
node *newNode();
struct node {
  int value;
  bool lazy;
  node *l, *r;
  node() : value(0), l(NULL), r(NULL), lazy(false) {}
  void expand(int a, int b) {
    if (!l) l = new node;
    if (!r) r = new node;
    if (lazy) {
      lazy = false;
      l->doLazy((a + b) / 2 - a + 1);
      r->doLazy((b - (a + b) / 2));
    }
  }
  void doLazy(int value) {
    lazy = true;
    this->value = value;
  }
  int query(int a, int b, int i, int j) {
    if (i > b || j < a) return 0;
    if (a >= i && b <= j) return value;
    expand(a, b);
    return l->query(a, (a + b) / 2, i, j) + r->query((a + b) / 2 + 1, b, i, j);
  }
  void update(int a, int b, int i, int j) {
    if (a > j || b < i) return;
    if (a >= i && b <= j) {
      doLazy(b - a + 1);
    } else {
      expand(a, b);
      l->update(a, (a + b) / 2, i, j);
      r->update((a + b) / 2 + 1, b, i, j);
      value = l->value + r->value;
    }
  }
};
int ans[200005];
int p[200005];
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> gravetos;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    gravetos.push_back({a, b});
    p[i + 1] = a;
  }
  sort(gravetos.rbegin(), gravetos.rend());
  int G = 0;
  int q;
  scanf("%d", &q);
  vector<pair<int, pair<int, int>>> queries;
  for (int i = 0; i < q; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    queries.push_back({p[a], {p[b], i}});
  }
  sort(queries.rbegin(), queries.rend());
  int Q = 0;
  node segtree;
  while (Q < q) {
    while (G < n && gravetos[G].first >= queries[Q].first) {
      segtree.update(1, 1000000000, gravetos[G].first + 1,
                     gravetos[G].first + gravetos[G].second);
      G++;
    }
    int a = queries[Q].first, b = queries[Q].second.first;
    ans[queries[Q].second.second] = b - a - segtree.query(1, 1000000000, a, b);
    Q++;
  }
  for (int i = 0; i < q; i++) printf("%d\n", ans[i]);
  return 0;
}
