#include <bits/stdc++.h>
using namespace std;
int blo[200010], n, m, x, y;
long long tree[200010 * 4], tag[200010 * 4], p[200010], l[200010], ans[200010];
struct node {
  int l, r, id;
} q[200010];
stack<int> s;
int fa[200010];
int get_fa(int x) {
  if (fa[x] == 0) return x;
  fa[x] = get_fa(fa[x]);
  return fa[x];
}
void Add(int l, int r, int id, int x, int val, bool flag) {
  if (l == r) {
    tree[id] += val;
    if (flag == 1) tree[id] = 0;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    Add(l, mid, id * 2, x, val, flag);
  else
    Add(mid + 1, r, id * 2 + 1, x, val, flag);
  tree[id] = tree[id * 2] + tree[id * 2 + 1];
}
long long Query(int l, int r, int id, int l1, int r1) {
  if (l1 <= l && r <= r1) return tree[id];
  int mid = (l + r) >> 1;
  long long res = 0;
  if (l1 <= mid) res += Query(l, mid, id * 2, l1, r1);
  if (r1 > mid) res += Query(mid + 1, r, id * 2 + 1, l1, r1);
  return res;
}
void Add(int x) {
  long long maxl = 0;
  while (!s.empty() && p[s.top()] <= l[x]) {
    maxl = max(l[s.top()], maxl);
    fa[s.top()] = x;
    Add(1, n, 1, s.top(), 0, 1);
    s.pop();
  }
  l[x] = max(l[x], maxl);
  if (!s.empty()) Add(1, n, 1, x, max(0ll, p[s.top()] - l[x]), 0);
  s.push(x);
}
bool cmp(node a, node b) {
  if (a.l != b.l) return a.l > b.l;
  return a.r < b.r;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d%I64d", &p[i], &l[i]);
    l[i] += p[i];
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &q[i].l, &q[i].r);
    q[i].id = i;
  }
  sort(q + 1, q + 1 + m, cmp);
  int now = n;
  for (int i = 1; i <= m; i++) {
    while (now >= q[i].l) Add(now--);
    if (now < get_fa(q[i].r) - 1)
      ans[q[i].id] = Query(1, n, 1, now + 1, get_fa(q[i].r) - 1);
  }
  for (int i = 1; i <= m; i++) printf("%I64d\n", ans[i]);
}
