#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
struct MYQUERY {
  int l, r, i;
} QS[200100];
int N, Q, P[200100], L[200100], g[200100], mx[200100], mycost[200100],
    ans[200100];
int f(int x) { return x == g[x] ? x : g[x] = f(g[x]); }
int cmp(MYQUERY q1, MYQUERY q2) { return q1.l < q2.l; }
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cout.tie(0);
  cin.tie(0);
  cin >> N;
  for (int(i) = 1; (i) <= (N); (i)++) cin >> P[i] >> L[i], mx[i] = P[i] + L[i];
  for (int(i) = 1; (i) <= (N + 1); (i)++) g[i] = i;
  cin >> Q;
  for (int(i) = 1; (i) <= (Q); (i)++) cin >> QS[i].l >> QS[i].r, QS[i].i = i;
  sort(QS + 1, QS + Q + 1, cmp);
  for (int i = Q, numadded = 0; i >= 1; i--) {
    for (int nextToAdd; (nextToAdd = N - numadded) >= QS[i].l; numadded++) {
      int rightEnd = P[nextToAdd] + L[nextToAdd];
      for (int j = nextToAdd + 1, prev = nextToAdd;
           j <= N && rightEnd >= P[j];) {
        g[nextToAdd] = g[f(prev)] = g[f(j)];
        if (mx[f(j)] < rightEnd) {
          mx[f(j)] = rightEnd;
          mycost[f(j)] = max(0, P[f(j) + 1] - rightEnd) + mycost[f(f(j) + 1)];
        }
        prev = j;
        j = f(j) + 1;
      }
      if (nextToAdd < N && rightEnd < P[nextToAdd + 1])
        mycost[nextToAdd] =
            P[nextToAdd + 1] - rightEnd + mycost[f(nextToAdd + 1)];
    }
    ans[QS[i].i] = mycost[f(QS[i].l)] - mycost[f(QS[i].r)];
  }
  for (int(i) = 1; (i) <= (Q); (i)++) cout << ans[i] << '\n';
}
