#include <bits/stdc++.h>
const long double eps = 1e-9;
using namespace std;
template <class T>
inline T MAX(const T &_a, const T &_b) {
  return ((_a > _b) ? _a : _b);
}
template <class T>
inline T MIN(const T &_a, const T &_b) {
  return ((_a < _b) ? _a : _b);
}
template <class T>
inline T MAX3(const T &_a, const T &_b, const T &_c) {
  return MAX(MAX(_a, _b), _c);
}
template <class T>
inline T MIN3(const T &_a, const T &_b, const T &_c) {
  return MIN(MIN(_a, _b), _c);
}
template <class T>
inline T MAX4(const T &_a, const T &_b, const T &_c, const T &_d) {
  return MAX(MAX3(_a, _b, _c), _d);
}
template <class T>
inline T MIN4(const T &_a, const T &_b, const T &_c, const T &_d) {
  return MIN(MIN3(_a, _b, _c), _d);
}
template <class T>
inline T ABS(const T &_a) {
  return ((_a < 0) ? -_a : _a);
}
template <class T>
inline T SQR(const T &_a) {
  return _a * _a;
}
template <class T>
inline T gcd(T _a, T _b) {
  for (T _r; (_r = _a % _b); _b = _r) _a = _b;
  return _b;
}
template <class T>
inline T lcm(const T &_a, const T &_b) {
  return (_a / gcd(_a, _b)) * _b;
}
template <class T>
inline bool BETW(const T &_a, const T &_b, const T &_c) {
  return (_a >= MIN(_b, _c) && _a <= MAX(_b, _c));
}
template <class T>
inline bool EXT(const T &_a, const T &_b, const T &_c) {
  return !BETW(_a, _b, _c);
}
const int MAXN = 200010, MAXL = 20;
int N, p[MAXN], h[MAXN], dist[MAXN];
int add[MAXL][MAXN], fall[MAXL][MAXN];
int main() {
  int i, q, x, y, j, k, M, ans;
  scanf("%d", &N);
  for (i = 1; i <= N; ++i) scanf("%d%d", p + i, h + i);
  fall[0][N] = N + 1;
  for (i = N - 1; i; --i) {
    j = i + 1, M = p[i] + h[i];
    while (j <= N && M >= p[j]) {
      M = MAX(M, dist[j]);
      j = fall[0][j];
    }
    fall[0][i] = j, dist[i] = M;
    add[0][i] = ((j <= N) ? p[j] - M : 0);
  }
  for (k = 1; k < MAXL; ++k)
    for (i = 1; i <= N; ++i) {
      add[k][i] = add[k - 1][i] + add[k - 1][fall[k - 1][i]];
      fall[k][i] = fall[k - 1][fall[k - 1][i]];
      if (!fall[k][i]) fall[k][i] = N + 1;
    }
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &x, &y);
    ans = 0, k = MAXL - 1;
    while (x < y) {
      while (k >= 0 && fall[k][x] > y) --k;
      if (k < 0) {
        printf("%d\n", ans);
        x = y;
      } else {
        ans += add[k][x];
        x = fall[k][x];
      }
    }
    if (k >= 0) printf("%d\n", ans);
  }
  return 0;
}
