#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, maxt = 1e9;
pair<int, int> p[maxn];
struct seg {
  int l, r, val;
  seg *lc, *rc;
  seg(int l_, int r_, int val_ = 0) {
    lc = NULL;
    rc = NULL;
    l = l_;
    r = r_;
    val = val_;
  }
  inline void add(int fi, int se) {
    if (l == fi && se == r) {
      val = se - fi + 1;
      return;
    }
    if (val == r - l + 1) return;
    int mid = (l + r) / 2;
    if (fi <= mid) {
      if (lc == NULL) lc = new seg(l, mid);
      lc->add(fi, min(se, mid));
    }
    if (se > mid) {
      if (rc == NULL) rc = new seg(mid + 1, r);
      rc->add(max(mid + 1, fi), se);
    }
    val = 0;
    if (lc != NULL) val += lc->val;
    if (rc != NULL) val += rc->val;
  }
  inline int get_val(int fi, int se) {
    if (l == fi && se == r) return val;
    if (val == r - l + 1) return se - fi + 1;
    int mid = (l + r) / 2;
    int ret = 0;
    if (fi <= mid && lc != NULL) ret += lc->get_val(fi, min(se, mid));
    if (se > mid && rc != NULL) ret += rc->get_val(max(mid + 1, fi), se);
    return ret;
  }
};
seg *mom = new seg(1, maxt);
int ans[maxn];
vector<pair<int, int> > v[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i].first >> p[i].second;
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(pair<int, int>(y, i));
  }
  int cnt = 0;
  for (int i = n; i >= 1; i--) {
    mom->add(p[i].first, min(maxt, p[i].first + p[i].second - 1));
    for (int j = 0; j < v[i].size(); j++) {
      int id = v[i][j].second;
      int s = v[i][j].first;
      ans[id] = (p[s].first - p[i].first) -
                (mom->get_val(p[i].first, p[s].first - 1));
    }
  }
  for (int i = 1; i <= m; i++) cout << ans[i] << "\n";
  return 0;
}
