#include <bits/stdc++.h>
using namespace std;
int nxt() {
  int res;
  scanf("%d", &res);
  return res;
}
const int N = 200000;
int l[N];
int p[N];
inline void solve() {
  int n = nxt();
  for (int i = 0; i < n; ++i) {
    p[i] = nxt();
    l[i] = nxt();
  }
  int sq = sqrt(n) + 1.5;
  int blocks = (n + sq - 1) / sq;
  vector<pair<int, int> > seg[blocks];
  int to[blocks];
  int ans[blocks];
  for (int i = 0; i < blocks; ++i) {
    int st = i * sq;
    int en = (i + 1) * sq;
    to[i] = 0;
    for (int j = st; j < n && j < en; ++j) {
      to[i] = max(to[i], p[j] + l[j]);
    }
    int curp = p[st];
    ans[i] = 0;
    for (int j = st; j < n && j < en; ++j) {
      if (curp < p[j]) {
        seg[i].push_back(make_pair(curp, p[j]));
        ans[i] += p[j] - curp;
      }
      curp = max(curp, p[j] + l[j]);
    }
  }
  vector<int> sums[blocks];
  for (int i = 0; i < blocks; ++i) {
    sums[i].assign(seg[i].size() + 1, 0);
    for (int j = int(seg[i].size()) - 1; j >= 0; --j) {
      sums[i][j] = sums[i][j + 1] + seg[i][j].second - seg[i][j].first;
    }
  }
  int q = nxt();
  for (int i = 0; i < q; ++i) {
    int L = nxt() - 1;
    int R = nxt() - 1;
    int st = L / sq;
    int en = R / sq;
    int j = L;
    int curp = p[L];
    int Ans = 0;
    for (; j <= R && j < (st + 1) * sq; ++j) {
      Ans += (curp < p[j]) ? (p[j] - curp) : 0;
      curp = max(curp, p[j] + l[j]);
    }
    for (int k = st + 1; k < en; ++k) {
      j = (k + 1) * sq;
      if (curp < p[k * sq]) {
        Ans += p[k * sq] - curp;
      }
      int pos =
          lower_bound((seg[k]).begin(), (seg[k]).end(), make_pair(curp, curp)) -
          seg[k].begin();
      Ans += sums[k][pos];
      if (pos > 0)
        Ans +=
            (seg[k][pos - 1].second > curp) ? seg[k][pos - 1].second - curp : 0;
      curp = max(curp, to[k]);
    }
    for (; j <= R; ++j) {
      Ans += (curp < p[j]) ? (p[j] - curp) : 0;
      curp = max(curp, p[j] + l[j]);
    }
    cout << Ans << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
