#include <bits/stdc++.h>
using namespace std;
struct fin {
  vector<int> T;
  fin() {}
  fin(int N) { T.resize(N + 1, 0); }
  int lastone(int x) { return x & (x ^ (x - 1)); }
  void put(int pos, int val) {
    for (int i = pos + 1; i < T.size(); i += lastone(i)) T[i] += val;
  }
  int get(int pos) {
    int ret = 0;
    for (int i = pos + 1; i > 0; i -= lastone(i)) ret += T[i];
    return ret;
  }
};
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  int N, Q;
  cin >> N;
  vector<int> X(N), D(N);
  map<int, int> P;
  vector<int> Pp;
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> D[i];
    P[X[i]] = 0;
    P[X[i] + D[i]] = 0;
  }
  int m = 0;
  for (auto it = P.begin(); it != P.end(); it++) {
    it->second = m++;
    Pp.push_back(it->first);
  }
  cin >> Q;
  vector<pair<pair<int, int>, int> > qu(Q);
  for (int i = 0; i < Q; i++) {
    cin >> qu[i].first.first >> qu[i].first.second;
    qu[i].first.second--;
    qu[i].first.first--;
    qu[i].second = i;
  }
  sort(qu.begin(), qu.end());
  vector<int> ans(Q);
  set<int> live;
  for (int i = 0; i < m - 1; i++) live.insert(i);
  int a = m - 2, b = N - 1;
  fin F(m - 1);
  for (int q = Q - 1; q >= 0; q--) {
    while (a >= 0 && Pp[a] >= X[qu[q].first.first]) {
      F.put(a, Pp[a + 1] - Pp[a]);
      a--;
    }
    while (b >= qu[q].first.first) {
      int x = X[b], y = X[b] + D[b];
      auto it = live.lower_bound(P[x]);
      while (it != live.end()) {
        if (Pp[*it] >= y) break;
        auto jt = it;
        it++;
        F.put(*jt, -(Pp[*jt + 1] - Pp[*jt]));
        live.erase(jt);
      }
      b--;
    }
    ans[qu[q].second] = F.get(P[X[qu[q].first.second]] - 1);
  }
  for (int i = 0; i < Q; i++) cout << ans[i] << "\n";
  return 0;
}
