#include <bits/stdc++.h>
using namespace std;
int n, m, p[200005], l[200005], fa[200005][20], mx[200005], f[200005][20];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &p[i], &l[i]);
  scanf("%d", &m);
  fa[n][0] = 0;
  int t = log2(n);
  for (int i = n - 1; i >= 1; i--) {
    int cur = i + 1;
    mx[i] = max(mx[i], p[i] + l[i]);
    while (cur && p[cur] <= p[i] + l[i])
      mx[i] = max(mx[i], mx[cur]), cur = fa[cur][0];
    fa[i][0] = cur;
    f[i][0] = p[cur] - mx[i];
  }
  for (int i = 1; i <= t; i++)
    for (int x = 1; x <= n; x++)
      f[x][i] = f[x][i - 1] + f[fa[x][i - 1]][i - 1],
      fa[x][i] = fa[fa[x][i - 1]][i - 1];
  while (m--) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (fa[l][0] > r)
      printf("0\n");
    else {
      int ans = 0;
      for (int i = t; i >= 0; i--)
        if (fa[l][i] && fa[l][i] <= r) ans += f[l][i], l = fa[l][i];
      printf("%d\n", ans);
    }
  }
  return 0;
}
