#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const int LOGN = 25;
int p[N], h[N];
int r[N], u[N][LOGN], s[N][LOGN];
int stk[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", p + i, h + i);
  }
  r[n - 1] = p[n - 1] + h[n - 1];
  memset(u, -1, sizeof u);
  int ptr = 0;
  stk[ptr++] = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    while (ptr > 0 && p[i] + h[i] >= p[stk[ptr - 1]] + h[stk[ptr - 1]]) {
      ptr--;
    }
    if (ptr > 0 && p[i] + h[i] >= p[stk[ptr - 1]]) {
      assert(p[i] + h[i] < p[stk[ptr - 1]] + h[stk[ptr - 1]]);
      assert(p[stk[ptr - 1]] + h[stk[ptr - 1]] <= r[stk[ptr - 1]]);
      r[i] = r[stk[ptr - 1]];
    } else {
      r[i] = p[i] + h[i];
    }
    u[i][0] = upper_bound(p + i, p + n, r[i]) - p;
    if (u[i][0] == n) {
      u[i][0] = -1;
    } else {
      s[i][0] = p[u[i][0]] - r[i];
    }
    stk[ptr++] = i;
  }
  for (int j = 1; 1 << j <= n; j++) {
    for (int i = 0; i < n; i++) {
      if (u[i][j - 1] > -1) u[i][j] = u[u[i][j - 1]][j - 1];
      s[i][j] = s[i][j - 1] + (u[i][j - 1] > -1 ? s[u[i][j - 1]][j - 1] : 0);
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    int log = 0;
    assert(x < y);
    while (1 << log <= y - x) {
      log++;
    }
    log--;
    int ans = 0;
    for (int i = log; i >= 0; i--) {
      if (u[x][i] == -1) continue;
      if (u[x][i] <= y) {
        ans += s[x][i];
        x = u[x][i];
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
