#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int block = 450;
int n, p[maxn], l[maxn], cost[maxn], nxt[maxn], f[maxn], g[maxn], aft[maxn],
    bit[maxn << 2];
void update(int pos, int x) {
  for (; pos <= n; pos += (pos & -pos)) bit[pos] = max(bit[pos], x);
}
int get(int pos) {
  int res = 0;
  for (; pos > 0; pos -= (pos & -pos)) res = max(res, bit[pos]);
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d%d", &p[i], &l[i]);
  for (int i = n - 1; i > -1; i--) {
    int pos = upper_bound(p, p + n, p[i] + l[i]) - p;
    f[i] = max(get(pos), p[i] + l[i]);
    update(i + 1, f[i]);
    aft[i] = upper_bound(p, p + n, f[i]) - p;
    if (i / block == (n - 1) / block) continue;
    if (aft[i] / block > i / block) {
      nxt[i] = aft[i];
      g[i] = f[i];
    } else {
      nxt[i] = nxt[aft[i]];
      g[i] = g[aft[i]];
      cost[i] = cost[aft[i]] + p[aft[i]] - f[i];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    int ans = 0;
    while (x / block < y / block && g[x] < p[y]) {
      ans += cost[x] + p[nxt[x]] - g[x];
      x = nxt[x];
    }
    if (x / block < y / block) {
      ans += cost[x];
      printf("%d\n", ans);
      continue;
    }
    while (f[x] < p[y]) {
      ans += p[aft[x]] - f[x];
      x = aft[x];
    }
    printf("%d\n", ans);
  }
  return 0;
}
