#include <bits/stdc++.h>
using namespace std;
stack<int> sta;
struct Query {
  int l, r, id;
} q[200000 + 5];
int N, Q;
long long farpos[200000 + 5], len[200000 + 5], pos[200000 + 5], ans[200000 + 5];
int fa[200000 + 5];
long long tree[200000 + 5], dp[200000 + 5];
void Init() {
  for (int i = 1; i <= 200000; i++) fa[i] = i;
}
int Lowbit(int i) { return i & (-i); }
bool cmp(Query a, Query b) {
  if (a.l == b.l) return a.r < b.r;
  return a.l > b.l;
}
int FindSet(int x) {
  if (fa[x] == x) return x;
  return fa[x] = FindSet(fa[x]);
}
void UniteSet(int x, int y) {
  int fx = FindSet(x);
  int fy = FindSet(y);
  if (fx == fy) return;
  fa[fx] = fy;
}
bool SameSet(int x, int y) { return FindSet(x) == FindSet(y); }
void Add(int i, long long val) {
  while (i <= N) {
    tree[i] += val;
    i += Lowbit(i);
  }
}
long long Sum(int i) {
  long long ret = 0;
  while (i >= 1) {
    ret += tree[i];
    i -= Lowbit(i);
  }
  return ret;
}
void GetBlock(int id) {
  farpos[id] = 1LL * pos[id] + 1LL * len[id];
  while (sta.empty() == false) {
    int top = sta.top();
    if (pos[top] <= farpos[id]) {
      sta.pop();
      UniteSet(top, id);
      farpos[id] = max(farpos[id], 1LL * farpos[top]);
      Add(top, -dp[top]);
      dp[top] = 0LL;
    } else
      break;
  }
  if (sta.empty() == false) {
    int top = sta.top();
    dp[id] = pos[top] - farpos[id];
    Add(id, dp[id]);
  }
  sta.push(id);
}
long long GetSum(int l, int r) { return Sum(r) - Sum(l - 1); }
int main() {
  Init();
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%lld %lld", &pos[i], &len[i]);
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    scanf("%d %d", &q[i].l, &q[i].r);
    q[i].id = i;
  }
  sort(q + 1, q + 1 + Q, cmp);
  int nl = N + 1;
  for (int i = 1; i <= Q; i++) {
    int l = q[i].l;
    int r = q[i].r;
    int id = q[i].id;
    while (nl > l) {
      GetBlock(nl - 1);
      nl--;
    }
    if (SameSet(l, r) == true)
      ans[id] = 0;
    else
      ans[id] = GetSum(l, fa[r] - 1);
  }
  for (int i = 1; i <= Q; i++) printf("%lld\n", ans[i]);
  return 0;
}
