#include <bits/stdc++.h>
using namespace std;
int n, p[200010], l[200010], q;
vector<int> v;
int e[200010][18], d[200010][18];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", p + i, l + i);
  }
  p[0] = 2000000005;
  v.push_back(0);
  for (int i = n; i > 0; i--) {
    int x = p[i] + l[i];
    for (int j = v.back(); p[j] <= x; j = v.back()) {
      x = max(x, p[j] + l[j]);
      v.pop_back();
    }
    e[i][0] = v.back();
    if (e[i][0]) {
      d[i][0] = p[e[i][0]] - x;
      l[i] = x - p[i];
    }
    v.push_back(i);
  }
  for (int i = 1; i < 18; i++) {
    for (int j = 1; j <= n; j++) {
      e[j][i] = e[e[j][i - 1]][i - 1];
      d[j][i] = d[j][i - 1] + d[e[j][i - 1]][i - 1];
    }
  }
  scanf("%d", &q);
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    int res = 0;
    for (int i = 18 - 1; i >= 0; i--) {
      if (e[x][i] != 0 && e[x][i] <= y) {
        res += d[x][i];
        x = e[x][i];
      }
    }
    printf("%d\n", res);
  }
}
