#include <bits/stdc++.h>
using namespace std;
const int MAXI = numeric_limits<int>::max() / 2;
const int MINI = numeric_limits<int>::min() / 2;
const long long MAXL = numeric_limits<long long>::max() / 2;
const long long MINL = numeric_limits<long long>::min() / 2;
static const int S = 1 << 19;
int N;
int sum[2 * S], ps[S];
bool cov[2 * S];
vector<pair<int, int> > qy[S / 2];
int ans[S / 2];
int inv[S / 2];
class ST {
 public:
  void update(int k, int l, int r, int s, int t) {
    if (r <= s || t <= l)
      return;
    else if (s <= l && r <= t) {
      sum[k] = ps[r] - ps[l];
      cov[k] = true;
    } else {
      if (cov[k]) return;
      int mid = (l + r) / 2;
      update(2 * k + 1, l, mid, s, t);
      update(2 * k + 2, mid, r, s, t);
      sum[k] = sum[2 * k + 1] + sum[2 * k + 2];
      cov[k] = false;
    }
  }
  int query(int k, int l, int r, int s, int t) {
    if (r <= s || t <= l)
      return 0;
    else if (s <= l && r <= t)
      return sum[k];
    else {
      int mid = (l + r) / 2;
      if (cov[k]) {
        return ps[min(t, r)] - ps[max(l, s)];
      }
      return query(2 * k + 1, l, mid, s, t) + query(2 * k + 2, mid, r, s, t);
    }
  }
};
struct seg {
  seg(int a = 0, int b = 0) : l(a), r(b) {}
  int l, r;
};
int main(int argc, char* argv[]) {
  int i, n;
  cin >> n;
  vector<seg> ss(n);
  for ((i) = (0); (i) < (n); ++(i)) {
    cin >> ss[i].l >> ss[i].r;
    ss[i].r += ss[i].l;
    ps[2 * i] = ss[i].l;
    ps[2 * i + 1] = ss[i].r;
  }
  sort(ps, ps + 2 * n);
  n = unique(ps, ps + 2 * n) - ps;
  map<int, int> st;
  for ((i) = (0); (i) < (n); ++(i)) st[ps[i]] = i;
  N = 1;
  while (N < n) N <<= 1;
  ST segt;
  for ((i) = (0); (i) < (ss.size()); ++(i)) {
    ss[i].l = st[ss[i].l];
    ss[i].r = st[ss[i].r];
  }
  int q, l, r;
  cin >> q;
  for ((i) = (0); (i) < (q); ++(i)) {
    cin >> l >> r;
    --l;
    --r;
    inv[i] = ps[ss[r].l] - ps[ss[l].l];
    qy[l].push_back(pair<int, int>(ss[r].l, i));
  }
  for ((i) = (ss.size() - 1); (i) >= (0); --(i)) {
    segt.update(0, 0, N - 1, ss[i].l, ss[i].r);
    for (int j = 0; j != qy[i].size(); ++j) {
      ans[qy[i][j].second] = segt.query(0, 0, N - 1, 0, qy[i][j].first);
    }
  }
  for ((i) = (0); (i) < (q); ++(i)) cout << inv[i] - ans[i] << endl;
  return 0;
}
