#include <bits/stdc++.h>
using namespace std;
int n, q;
int n1, n2;
int x[200010];
int y[200010];
int sv[200010];
int ans[200010];
int pai[200010];
int mnX[200010];
int peso[200010];
int mxRange[200010];
vector<int> pilha;
vector<pair<pair<int, int>, int> > v;
int find(int i) {
  if (pai[i] == i) return i;
  return pai[i] = find(pai[i]);
}
void join(int i, int j) {
  i = find(i);
  j = find(j);
  if (i == j) return;
  if (peso[i] < peso[j]) swap(i, j);
  pai[j] = i;
  if (peso[i] == peso[j]) peso[i]++;
  if (x[mnX[i]] > x[mnX[j]]) mnX[i] = mnX[j];
  mxRange[i] = max(mxRange[i], mxRange[j]);
}
void init() {
  for (int g = 1; g <= n; g++) {
    pai[g] = mnX[g] = g;
    mxRange[g] = x[g] + y[g];
  }
}
int main() {
  scanf("%d", &n);
  for (int g = 1; g <= n; g++) scanf("%d %d", &x[g], &y[g]);
  init();
  scanf("%d", &q);
  for (int g = 1; g <= q; g++) {
    scanf("%d %d", &n1, &n2);
    v.push_back({{n1, n2}, g});
  }
  sort(v.begin(), v.end());
  int p = q - 1;
  for (int g = n; g > 0; g--) {
    while (!pilha.empty()) {
      if (x[pilha.back()] > mxRange[find(g)]) break;
      join(pilha.back(), g);
      pilha.pop_back();
    }
    if (pilha.empty())
      sv[g] = 0;
    else
      sv[g] = sv[pilha.back()] + (x[pilha.back()] - mxRange[find(g)]);
    pilha.push_back(g);
    while (p >= 0 && v[p].first.first == g) {
      ans[v[p].second] = sv[g] - sv[mnX[find(v[p].first.second)]];
      p--;
    }
  }
  for (int g = 1; g <= q; g++) printf("%d\n", ans[g]);
}
