#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 Query {
  int left, right, index;
} QS[200100];
int N, Q, P[200100], L[200100], mx[200100], ans[200100], mycost[200100],
    g[200100];
int f(int x) { return x == g[x] ? x : g[x] = f(g[x]); }
int cmp(const Query q1, const Query q2) { return q1.left < q2.left; }
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], g[i] = i, mx[i] = P[i] + L[i];
  g[N + 1] = N + 1;
  cin >> Q;
  for (int(i) = 1; (i) <= (Q); (i)++)
    cin >> QS[i].left >> QS[i].right, QS[i].index = 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].left; numadded++) {
      int rightEnd = P[nextToAdd] + L[nextToAdd];
      for (int j = nextToAdd + 1, prev = nextToAdd;
           j <= N && rightEnd >= P[j];) {
        int fj = f(j);
        g[nextToAdd] = g[f(prev)] = fj;
        mx[fj] = max(mx[fj], rightEnd);
        mycost[fj] = max(0, P[fj + 1] - mx[fj]) + mycost[f(fj + 1)];
        prev = j;
        j = fj + 1;
      }
      if (nextToAdd < N && rightEnd < P[nextToAdd + 1])
        mycost[nextToAdd] =
            P[nextToAdd + 1] - rightEnd + mycost[f(nextToAdd + 1)];
    }
    ans[QS[i].index] = mycost[f(QS[i].left)] - mycost[f(QS[i].right)];
  }
  for (int(i) = 1; (i) <= (Q); (i)++) cout << ans[i] << '\n';
}
