#include <bits/stdc++.h>
using namespace std;
inline int min(int _a, int _b) { return _a < _b ? _a : _b; }
inline int max(int _a, int _b) { return _a > _b ? _a : _b; }
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 201000;
template <class _T>
inline void rd(_T &_a) {
  int _f = 0, _ch = getchar();
  _a = 0;
  while (_ch < '0' || _ch > '9') {
    if (_ch == '-') _f = 1;
    _ch = getchar();
  }
  while (_ch >= '0' && _ch <= '9')
    _a = (_a << 1) + (_a << 3) + _ch - '0', _ch = getchar();
  if (_f) _a = -_a;
}
struct node {
  int l, r;
} a[maxn];
int n, m;
int l[maxn], r[maxn];
long long sum[maxn], ans[maxn];
int fr[maxn], to[maxn];
int fa[maxn];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
vector<int> ques[maxn];
deque<int> q;
void solve(int x, int id) {
  int tmp = to[id];
  ans[id] = sum[x] - sum[find(tmp)];
}
int main() {
  rd(n);
  for (int i = 1; i <= n; ++i) {
    rd(a[i].l);
    rd(a[i].r);
    a[i].r += a[i].l;
    fa[i] = i;
  }
  rd(m);
  for (int i = 1; i <= m; ++i) {
    rd(fr[i]);
    rd(to[i]);
    ques[fr[i]].push_back(i);
  }
  for (int i = n; i >= 1; --i) {
    l[i] = a[i].l;
    r[i] = a[i].r;
    while (!q.empty()) {
      if (l[q.front()] > r[i]) break;
      r[i] = max(r[i], r[q.front()]);
      fa[find(q.front())] = i;
      q.pop_front();
    }
    if (!q.empty())
      sum[i] = sum[q.front()] + l[q.front()] - r[i];
    else
      sum[i] = 0;
    q.push_front(i);
    for (int j = 0; j < ques[i].size(); ++j) {
      solve(i, ques[i][j]);
    }
  }
  for (int i = 1; i <= m; ++i) printf("%lld\n", ans[i]);
  return 0;
}
