#include <bits/stdc++.h>
const int MAXN = 2e5 + 5;
int p[MAXN], l[MAXN], n, q;
struct Node {
  int l, r, id;
  bool operator<(const Node &t) const { return l > t.l; }
} a[MAXN];
int sm[MAXN << 2];
inline void pushup(int x) { sm[x] = sm[((x) << 1)] + sm[((x) << 1 | 1)]; }
inline void update(int x, int l, int r, int ps, int d) {
  if (l == r) {
    sm[x] = d;
    return;
  }
  int mid = (l + r) >> 1;
  if (ps <= mid)
    update(((x) << 1), l, mid, ps, d);
  else
    update(((x) << 1 | 1), mid + 1, r, ps, d);
  pushup(x);
}
inline int query(int x, int l, int r, int L, int R) {
  if (L > R) return 0;
  if (l == L && r == R) return sm[x];
  int mid = (l + r) >> 1;
  if (R <= mid) return query(((x) << 1), l, mid, L, R);
  if (L > mid) return query(((x) << 1 | 1), mid + 1, r, L, R);
  return query(((x) << 1), l, mid, L, mid) +
         query(((x) << 1 | 1), mid + 1, r, mid + 1, R);
}
std::stack<int> S;
int r[MAXN];
int f[MAXN], ans[MAXN];
inline int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
inline void merge(int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return;
  f[fy] = fx;
}
inline void add(int x) {
  while (!S.empty() && p[S.top()] <= r[x]) {
    r[x] = std::max(r[x], r[S.top()]);
    merge(x, S.top());
    update(1, 1, n, S.top(), 0);
    S.pop();
  }
  if (!S.empty()) update(1, 1, n, x, std::max(0, p[S.top()] - r[x]));
  S.push(x);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d", p + i, l + i), r[i] = l[i] + p[i], f[i] = i;
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) scanf("%d%d", &a[i].l, &a[i].r), a[i].id = i;
  std::sort(a + 1, a + q + 1);
  int now = n;
  for (int i = 1; i <= q; ++i) {
    while (now >= 1 && now >= a[i].l) {
      add(now--);
    }
    ans[a[i].id] = query(1, 1, n, a[i].l, find(a[i].r) - 1);
  }
  for (int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
  return 0;
}
