#include <bits/stdc++.h>
using namespace std;
int n, T, size, L[200000 + 5], R[200000 + 5], q[200000 + 5];
long long Ans[200000 + 5];
struct Querys {
  int l, r, id;
  Querys(int _l = 0, int _r = 0, int _id = 0) { l = _l, r = _r, id = _id; }
  bool operator<(const Querys a) const { return r < a.r; }
} Ask[200000 + 5];
struct Segment_Tree {
  long long num, delta;
} h[600000 + 5];
inline void apply(int x, int d) {
  h[x].num += d;
  h[x].delta += d;
}
inline void push(int x) {
  if (h[x].delta) {
    apply(x << 1, h[x].delta);
    apply(x << 1 | 1, h[x].delta);
    h[x].delta = 0;
  }
}
inline void Modify(int x, int l, int r, int s, int t, int d) {
  if (l == s && r == t) {
    apply(x, d);
    return;
  }
  push(x);
  int mid = l + r >> 1;
  if (t <= mid)
    Modify(x << 1, l, mid, s, t, d);
  else if (s > mid)
    Modify(x << 1 | 1, mid + 1, r, s, t, d);
  else
    Modify(x << 1, l, mid, s, mid, d),
        Modify(x << 1 | 1, mid + 1, r, mid + 1, t, d);
}
inline long long Query(int x, int l, int r, int t) {
  if (l == r) return h[x].num;
  push(x);
  int mid = l + r >> 1;
  if (t <= mid)
    return Query(x << 1, l, mid, t);
  else
    return Query(x << 1 | 1, mid + 1, r, t);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", L + i, R + i);
    R[i] += L[i];
  }
  scanf("%d", &T);
  for (int i = 1; i <= T; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    Ask[i] = Querys(l, r, i);
  }
  sort(Ask + 1, Ask + T + 1);
  int t = 1;
  for (int i = 1; i <= n; i++) {
    for (; R[q[size]] <= R[i] && size; size--)
      if (R[q[size]] < L[i])
        Modify(1, 1, n, q[size - 1] + 1, q[size], L[i] - R[q[size]]);
    q[++size] = i;
    while (Ask[t].r == i && t <= T) {
      Ans[Ask[t].id] = Query(1, 1, n, Ask[t].l);
      t++;
    }
  }
  for (int i = 1; i <= T; i++) printf("%I64d\n", Ans[i]);
  return 0;
}
