#include <bits/stdc++.h>
using namespace std;
int n, p[200005], h[200005], _next[200005];
int R[200005];
int f[200005][20], d[200005][20];
int it[4 * 200005];
void update(int r, int k, int l, int u, int val) {
  if (u < k || u > l) return;
  if (u == k && k == l) {
    it[r] = val;
    return;
  }
  int g = (k + l) / 2;
  update(2 * r, k, g, u, val);
  update(2 * r + 1, g + 1, l, u, val);
  it[r] = max(it[2 * r], it[2 * r + 1]);
}
int get(int r, int k, int l, int u, int v) {
  if (v < k || u > l) return 0;
  if (u <= k && l <= v) return it[r];
  int g = (k + l) / 2;
  int t1 = get(2 * r, k, g, u, v);
  int t2 = get(2 * r + 1, g + 1, l, u, v);
  return max(t1, t2);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d %d", &p[i], &h[i]);
  p[n + 1] = 2000000000;
  R[n] = p[n] + h[n];
  update(1, 1, n, n, R[n]);
  for (int i = n - 1; i >= 1; --i) {
    int j = upper_bound(p + i, p + n + 1, p[i] + h[i]) - p - 1;
    R[i] = max(p[i] + h[i], get(1, 1, n, i, j));
    update(1, 1, n, i, R[i]);
  }
  for (int i = n; i >= 1; --i)
    _next[i] = upper_bound(p + i, p + n + 1, R[i]) - p;
  int m = int(log2(n)) + 1;
  for (int i = 1; i <= n; ++i) f[i][0] = p[_next[i]] - R[i], d[i][0] = _next[i];
  for (int k = 0; k <= m; ++k) d[n + 1][k] = n + 1;
  for (int k = 1; k <= m; ++k)
    for (int i = 1; i <= n; ++i) {
      f[i][k] = f[i][k - 1] + f[d[i][k - 1]][k - 1];
      d[i][k] = d[d[i][k - 1]][k - 1];
    }
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int u, v;
    scanf("%d %d", &u, &v);
    int ans = 0;
    for (int k = m; k >= 0; --k) {
      if (d[u][k] <= v) ans += f[u][k], u = d[u][k];
    }
    printf("%d\n", ans);
  }
}
