#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200002;
const int B = 450;
int n;
int p[MAXN];
int l[MAXN];
int est[MAXN];
int bal[MAXN];
int fine[MAXN];
int costo[MAXN];
int quanto[MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i] >> l[i];
  for (int i = n; i > 0; i--) {
    est[i] = i + 1;
    bal[i] = p[i] + l[i];
    while (est[i] <= n && p[est[i]] <= bal[i]) {
      bal[i] = max(bal[i], bal[est[i]]);
      est[i] = est[est[i]];
    }
  }
  for (int i = 1; i <= n; i++) bal[i] = p[est[i]] - bal[i];
  for (int i = n; i > 0; i -= B) fine[i] = i;
  for (int i = n; i > 0; i--)
    if (fine[i] == 0) fine[i] = fine[i + 1];
  for (int i = n - B; i > 0; i--) {
    if (fine[i] > i && est[i] <= fine[i]) {
      costo[i] = bal[i] + costo[est[i]];
      quanto[i] = quanto[est[i]];
    } else {
      costo[i] = bal[i];
      quanto[i] = est[i];
    }
  }
  int q;
  for (cin >> q; q > 0; q--) {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    while (fine[a] < fine[b] && quanto[a] <= b) {
      ans += costo[a];
      a = quanto[a];
    }
    while (est[a] <= b) {
      ans += bal[a];
      a = est[a];
    }
    cout << ans << '\n';
  }
  return 0;
}
