#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int L, R, t[4 * 310 * 1004], ans, was[310 * 1004], r[310 * 1004], n, q,
    l[310 * 1004], pr[310 * 1004][33], g[310 * 1004 * 4];
long long d[310 * 1004][33], p[310 * 1004];
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = p[tr] + l[tr];
    g[v] = tl;
  } else {
    int m = (tl + tr) >> 1;
    build(v + v, tl, m);
    build(v + v + 1, m + 1, tr);
    t[v] = max(t[v + v], t[v + v + 1]);
    if (t[v] == t[v + v])
      g[v] = g[v + v];
    else
      g[v] = g[v + v + 1];
  }
}
pair<int, int> get(int v, int tl, int tr, int l, int r) {
  if (l > r) return make_pair(0, 0);
  if (tl == l && tr == r) return make_pair(t[v], g[v]);
  int m = (tl + tr) >> 1;
  return max(get(v + v, tl, m, l, min(r, m)),
             get(v + v + 1, m + 1, tr, max(l, m + 1), r));
}
int Find(int x) {
  int l = 0, r = 0, m = 0;
  l = 1;
  r = n + 1;
  while (r - l > 1) {
    m = (r + l) >> 1;
    if (p[m] > x)
      r = m;
    else
      l = m;
  }
  return l;
}
int pre(int i) {
  if (was[i]) return r[i];
  was[i] = 1;
  int v = i;
  v = get(1, 1, n, i, Find(p[i] + l[i])).second;
  if (v == i) return r[i] = i;
  return r[i] = pre(v);
}
int calc(int l, int r) {
  ans = 0;
  for (int j = 30; j >= 0; j--) {
    if (pr[l][j] <= r) {
      ans += d[l][j];
      l = pr[l][j];
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i] >> l[i];
  build(1, 1, n);
  was[n] = 1;
  r[n] = n;
  for (int i = 0; i <= 30; i++) pr[n + 1][i] = n + 1;
  p[n + 1] = ((int)2e9 + 9);
  for (int i = 1; i <= n; i++)
    if (!was[i]) pre(i);
  for (int i = n; i > 0; i--) {
    int v = Find(p[r[i]] + l[r[i]]) + 1;
    pr[i][0] = v;
    d[i][0] = p[v] - (p[r[i]] + l[r[i]]);
    for (int j = 1; j <= 30; j++) {
      pr[i][j] = pr[pr[i][j - 1]][j - 1];
      d[i][j] = d[i][j - 1] + d[pr[i][j - 1]][j - 1];
    }
  }
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> L >> R;
    cout << calc(L, R) << "\n";
  }
  return 0;
}
