#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
const long long maxn = 5e5 + 54;
const long long mod = 2520;
const long long base = 1e18;
long long p[maxn];
long long l[maxn];
long long nxt[maxn];
long long st[4 * maxn];
long long anc[maxn][20];
long long cst[maxn][20];
void update(long long id, long long left, long long right, long long x,
            long long diff) {
  if (x > right || x < left) return;
  if (left == right) {
    st[id] = diff;
    return;
  }
  long long mid = (left + right) / 2;
  update(id * 2, left, mid, x, diff);
  update(id * 2 + 1, mid + 1, right, x, diff);
  st[id] = max(st[id * 2], st[id * 2 + 1]);
}
long long get(long long id, long long left, long long right, long long x,
              long long y) {
  if (x > right || y < left) return 0;
  if (x <= left && y >= right) return st[id];
  long long mid = (left + right) / 2;
  return max(get(id * 2, left, mid, x, y),
             get(id * 2 + 1, mid + 1, right, x, y));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (fopen("t.inp", "r")) {
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
  }
  long long n;
  cin >> n;
  vector<long long> vt;
  for (int i = 1; i <= n; i++) {
    cin >> p[i] >> l[i];
    vt.push_back(p[i]);
  }
  for (int i = n; i >= 1; i--) {
    nxt[i] = i;
    long long h = p[i] + l[i];
    h = upper_bound(vt.begin(), vt.end(), h) - vt.begin();
    nxt[i] = max(nxt[i], get(1, 1, n, i, h));
    update(1, 1, n, i, nxt[i]);
  }
  for (int i = 1; i <= n; i++) {
    update(1, 1, n, i, p[i] + l[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (nxt[i] != n) {
      anc[i][0] = nxt[i] + 1;
      cst[i][0] = p[nxt[i] + 1] - (get(1, 1, n, i, nxt[i]));
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = 1; j < 20; j++) {
      if (anc[i][j - 1] == 0) break;
      anc[i][j] = anc[anc[i][j - 1]][j - 1];
      cst[i][j] = cst[i][j - 1] + cst[anc[i][j - 1]][j - 1];
    }
  }
  long long q;
  cin >> q;
  while (q--) {
    long long x, y;
    cin >> x >> y;
    if (nxt[x] >= y) {
      cout << 0 << "\n";
      continue;
    }
    long long l = 0, h = n;
    while (l <= h) {
      long long mid = (l + h) / 2;
      long long nw = x;
      for (int j = 19; j >= 0; j--) {
        if (mid & (1ll << j)) {
          nw = anc[nw][j];
        }
      }
      if (nw == 0 || nxt[nw] >= y)
        h = mid - 1;
      else
        l = mid + 1;
    }
    long long nw = x;
    long long ans = 0;
    for (int j = 19; j >= 0; j--) {
      if (l & (1ll << j)) {
        ans += cst[nw][j];
        nw = anc[nw][j];
      }
    }
    cout << ans << "\n";
  }
}
