#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int fa[210000], f[210000], q[210000], tot, ff[22][210000], d[22][210000], Q, n,
    p[210000], l[210000];
void add(int x) {
  ff[0][x] = fa[x];
  d[0][x] = p[fa[x]] - f[x];
  for (int i = 1; i <= 20; ++i) {
    ff[i][x] = ff[i - 1][ff[i - 1][x]];
    d[i][x] = d[i - 1][x] + d[i - 1][ff[i - 1][x]];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &p[i], &l[i]);
  for (int i = n; i >= 1; --i) {
    int L = 1, R = tot, mid;
    while (L <= R) {
      mid = (L + R) / 2;
      if (p[q[mid]] - p[i] <= l[i])
        R = mid - 1;
      else
        L = mid + 1;
    }
    R++;
    if (R > tot) {
      fa[i] = i + 1;
      f[i] = p[i] + l[i];
    } else {
      fa[i] = fa[q[R]];
      f[i] = max(p[i] + l[i], f[q[R]]);
    }
    while (tot && f[i] > f[q[tot]]) tot--;
    q[++tot] = i;
    add(i);
  }
  scanf("%d", &Q);
  for (int i = 1; i <= Q; ++i) {
    int x, y, ans = 0;
    scanf("%d%d", &x, &y);
    for (int j = 20; j >= 0; --j)
      if (ff[j][x] != 0 && y >= ff[j][x]) {
        ans += d[j][x];
        x = ff[j][x];
      }
    printf("%d\n", ans);
  }
}
