#include <bits/stdc++.h>
using namespace std;
const int maxn = 400000;
const int inf = 1e9;
int n, k;
int fa[maxn];
long long sum[maxn], p[maxn], h[maxn];
struct node {
  long long pos, r;
} ask[maxn], sta[maxn];
int top;
int ans[maxn];
vector<int> vec[maxn];
int find(int x) {
  if (fa[x] != x) fa[x] = find(fa[x]);
  return fa[x];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    cin >> p[i] >> h[i];
  }
  cin >> k;
  for (int i = 1; i <= k; i++) {
    cin >> ask[i].pos >> ask[i].r;
    vec[ask[i].pos].push_back(i);
  }
  sta[++top] = (node){n, p[n]};
  sum[n] = 0;
  for (int i = n - 1; i >= 1; i--) {
    long long to = p[i] + h[i];
    while (top && to >= p[sta[top].pos]) {
      node x = sta[top];
      top--;
      fa[x.pos] = i;
      to = max(to, x.r);
    }
    if (top) {
      int x = sta[top].pos;
      sum[i] = sum[x] + (p[x] - to);
    } else
      sum[i] = 0;
    sta[++top] = (node){i, to};
    for (auto v : vec[i]) {
      ans[v] = sum[i] - sum[find(ask[v].r)];
    }
  }
  for (int i = 1; i <= k; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
