#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 11;
int n, sum[N << 2], x[N], ll[N], dp[N];
pair<int, int> seg[N << 2];
void add(int p, int v, int L = 0, int R = n - 1, int id = 1) {
  if (L == R) {
    seg[id].first = v;
    seg[id].second = p;
    return;
  }
  int m = (L + R) >> 1;
  if (p >= L && p <= m)
    add(p, v, L, m, id << 1);
  else if (p > m && p <= R)
    add(p, v, m + 1, R, id << 1 | 1);
  if (seg[id << 1] < seg[id << 1 | 1])
    seg[id].second = seg[id << 1 | 1].second;
  else
    seg[id].second = seg[id << 1].second;
  seg[id].first = max(seg[id << 1].first, seg[id << 1 | 1].first);
}
void add1(int p, int v, int L = 0, int R = n - 1, int id = 1) {
  if (L == R) {
    sum[id] = v;
    return;
  }
  int m = (L + R) >> 1;
  if (p >= L && p <= m)
    add1(p, v, L, m, id << 1);
  else if (p > m && p <= R)
    add1(p, v, m + 1, R, id << 1 | 1);
  sum[id] = min(sum[id << 1], sum[id << 1 | 1]);
}
pair<int, int> find(int l, int r, int L = 0, int R = n - 1, int id = 1) {
  if (r < L || R < l) return {INT_MIN, 0};
  if (l <= L && R <= r) {
    return seg[id];
  }
  int m = (L + R) >> 1;
  pair<int, int> aa = find(l, r, L, m, id << 1);
  pair<int, int> bb = find(l, r, m + 1, R, id << 1 | 1);
  if (aa.first > bb.first)
    return aa;
  else
    return bb;
}
int find1(int l, int r, int L = 0, int R = n - 1, int id = 1) {
  if (r < l) return INT_MAX;
  if (r < L || R < l) return INT_MAX;
  if (l <= L && R <= r) {
    return sum[id];
  }
  int m = (L + R) >> 1;
  return min(find1(l, r, L, m, id << 1), find1(l, r, m + 1, R, id << 1 | 1));
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x[i], &ll[i]);
    add(i, x[i] + ll[i]);
  }
  for (int i = 1; i < 4 * N; i++) sum[i] = INT_MAX;
  dp[n - 1] = 0;
  add1(n - 1, 0);
  for (int i = n - 2; i >= 0; i--) {
    int xx = upper_bound(x, x + n, x[i] + ll[i]) - x;
    if (xx == n) {
      add1(i, 0);
      dp[i] = 0;
    } else {
      int min1 = find1(i + 1, xx - 1);
      int min2 = dp[xx];
      if ((x[xx] - x[i] - ll[i]) > 0) min2 += (x[xx] - x[i] - ll[i]);
      dp[i] = min(min1, min2);
      add1(i, dp[i]);
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    int ans = dp[l - 1];
    pair<int, int> I = find(l - 1, r - 2);
    ans -= dp[I.second];
    if (x[r - 1] - I.first > 0) ans += (x[r - 1] - I.first);
    printf("%d\n", ans);
  }
  return 0;
}
