#include <bits/stdc++.h>
using namespace std;
inline int powmod(int a, int b) {
  int tmp = 1;
  for (; b; b >>= 1) {
    if (b & 1) tmp = tmp * a;
    a = a * a;
  }
  return tmp;
}
template <class T>
inline void R(T &xx) {
  xx = 0;
  char ch = getchar();
  bool F = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') F = 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
  if (F) xx = -xx;
}
pair<int, int> qu[200011];
int n, m, fa[200011], l[200011], r[200011], sum[200011], ans[200011];
deque<int> q;
vector<int> g[200011];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
inline void sol(int x, int id) { ans[id] = sum[x] - sum[find(qu[id].second)]; }
int main() {
  R(n);
  for (int i = (1); i <= (n); i++) fa[i] = i;
  for (int i = (1); i <= (n); i++) R(l[i]), R(r[i]), r[i] += l[i];
  R(m);
  for (int i = (1); i <= (m); i++)
    R(qu[i].first), R(qu[i].second), g[qu[i].first].push_back(i);
  for (int i = (n); i >= (1); i--) {
    for (; !q.empty() && l[q.front()] <= r[i]; q.pop_front())
      r[i] = max(r[i], r[q.front()]), fa[find(q.front())] = i;
    sum[i] = ((int)q.size()) ? sum[q.front()] + l[q.front()] - r[i] : 0;
    q.push_front(i);
    for (int j = 0; j < (int)(((int)g[i].size())); j++) sol(i, g[i][j]);
  }
  for (int i = (1); i <= (m); i++) printf("%d\n", ans[i]);
  return 0;
}
