#include <bits/stdc++.h>
using namespace std;
const int limite = 1000000;
const int primero = 1 << 18;
const int tope = 1 << 19;
const int infinito = 1000000001;
int coste[tope];
void inserta(int pos, int val) {
  pos += primero;
  coste[pos] = val;
  while (pos > 1) {
    pos /= 2;
    coste[pos] = coste[2 * pos] + coste[2 * pos + 1];
  }
}
int costeantes(int pos) {
  pos += primero;
  int c = coste[pos];
  while (pos > 1) {
    if (pos % 2 == 1) c += coste[pos - 1];
    pos /= 2;
  }
  return c;
}
int siguiente(int pos) {
  pos += primero;
  for (;;) {
    if (pos == 1) return -1;
    if (pos % 2 == 0 and coste[pos + 1]) {
      pos++;
      break;
    }
    pos /= 2;
  }
  while (pos < primero) {
    if (coste[2 * pos])
      pos = 2 * pos;
    else
      pos = 2 * pos + 1;
  }
  return pos - primero;
}
int n;
int p[limite], l[limite];
int x[limite], y[limite];
vector<int> listaq[limite];
int casos;
int solq[limite];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i] >> l[i];
  cin >> casos;
  for (int cas = 1; cas <= casos; cas++) {
    cin >> x[cas] >> y[cas];
    listaq[x[cas]].push_back(cas);
  }
  for (int i = n; i >= 1; i--) {
    for (;;) {
      int nexti = siguiente(i);
      if (nexti == -1) break;
      if (p[i] + l[i] >= p[nexti]) {
        inserta(nexti, 0);
      } else {
        if (p[nexti] - (p[i] + l[i]) < coste[nexti + primero])
          inserta(nexti, p[nexti] - (p[i] + l[i]));
        break;
      }
    }
    vector<int> lis = listaq[i];
    for (int j = 0; j < int(lis.size()); j++) {
      int indq = lis[j];
      solq[indq] = costeantes(y[indq]);
    }
    inserta(i, infinito);
  }
  for (int i = 1; i <= casos; i++) cout << solq[i] << endl;
}
