#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
long long p[200009], len[200009], dom[200009], s[200009 << 2], vis[200009],
    ans[200009];
vector<pair<int, int> > adj[200009];
long long tap(int l, int r, int nd, int x, int y) {
  if (l > y or x > r) return 0;
  if (l <= x and y <= r) return s[nd];
  int mid = (x + y) >> 1;
  long long i1 = tap(l, r, nd << 1, x, mid);
  long long i2 = tap(l, r, nd << 1 | 1, mid + 1, y);
  return i1 + i2;
}
void upd(int p, int v, int nd, int x, int y) {
  if (x == y) {
    s[nd] = v;
    return;
  }
  int mid = (x + y) >> 1;
  if (p <= mid)
    upd(p, v, nd << 1, x, mid);
  else
    upd(p, v, nd << 1 | 1, mid + 1, y);
  s[nd] = s[nd << 1] + s[nd << 1 | 1];
}
bool lazy[200009 << 2];
set<int> h;
void pd(int l, int r, int nd, int x, int y) {
  if (l > y or x > r) return;
  if (l <= x and y <= r) {
    lazy[nd] = 1;
    return;
  }
  if (lazy[nd]) {
    lazy[nd << 1] = lazy[nd << 1 | 1] = 1;
    lazy[nd] = 0;
  }
  int mid = (x + y) >> 1;
  pd(l, r, nd << 1, x, mid);
  pd(l, r, nd << 1 | 1, mid + 1, y);
}
bool tp(int p, int nd, int x, int y) {
  if (x == y) return lazy[nd];
  if (lazy[nd]) {
    lazy[nd << 1] = lazy[nd << 1 | 1] = 1;
    lazy[nd] = 0;
  }
  int mid = (x + y) >> 1;
  if (p <= mid)
    return tp(p, nd << 1, x, mid);
  else
    return tp(p, nd << 1 | 1, mid + 1, y);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", p + i, len + i);
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    adj[l].push_back(make_pair(r, i));
  }
  stack<pair<int, int> > s;
  stack<int> tin;
  for (int i = n; i >= 1; i--) {
    int mx = p[i] + len[i];
    while (!s.empty() and s.top().first <= mx) {
      umax(mx, s.top().second);
      s.pop();
    }
    s.push(make_pair(p[i], mx));
    dom[i] = mx;
  }
  fill(vis, vis + 200009, 1000000000000000007);
  for (int i = n; i >= 1; i--) {
    int pos = lower_bound(p + 1, p + n + 1, dom[i] + 1) - p;
    typeof((h).begin()) ti = h.lower_bound(i + 1);
    while (ti != h.end()) {
      if (*ti >= pos) break;
      tin.push(*ti);
      ti++;
    }
    while (!tin.empty()) {
      upd(tin.top(), 0, 1, 1, n);
      vis[tin.top()] = 0;
      tin.pop();
    }
    if (pos <= n and vis[pos] > p[pos] - dom[i]) {
      vis[pos] = p[pos] - dom[i];
      upd(pos, p[pos] - dom[i], 1, 1, n);
      h.insert(pos);
    }
    for (typeof((adj[i]).begin()) it = (adj[i]).begin(); it != (adj[i]).end();
         it++)
      ans[it->second] = tap(i, it->first, 1, 1, n);
  }
  for (int i = 1; i <= q; i++) printf("%lld\n", ans[i]);
  return 0;
}
