#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200 * 1000 + 10;
int pr[20][MAXN];
int p[MAXN], l[MAXN];
int cost[20][MAXN];
int find(int x, int y) {
  int ind = 0;
  while (ind < 20 && pr[ind][x] <= y) ind++;
  int ans = 0;
  for (int i = ind - 1; i >= 0; i--) {
    if (pr[i][x] <= y) {
      ans += cost[i][x];
      x = pr[i][x];
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i] >> l[i];
  vector<int> now;
  for (int i = n - 1; i >= 0; i--) {
    if (now.empty()) {
      now.push_back(i);
      pr[0][i] = i;
    } else {
      int ne = now.back();
      int la = -1;
      while (!now.empty() && p[ne] + l[ne] <= p[i] + l[i]) {
        la = ne;
        now.pop_back();
        if (!now.empty()) ne = now.back();
      }
      if (!now.empty())
        pr[0][i] = now.back();
      else
        pr[0][i] = la;
      now.push_back(i);
    }
  }
  for (int i = 0; i < n; i++) cost[0][i] = max(0, p[pr[0][i]] - (p[i] + l[i]));
  for (int i = 1; i < 20; i++)
    for (int j = 0; j < n; j++) {
      cost[i][j] = cost[i - 1][j] + cost[i - 1][pr[i - 1][j]];
      pr[i][j] = pr[i - 1][pr[i - 1][j]];
    }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << find(x, y) << '\n';
  }
  return 0;
}
