#include <bits/stdc++.h>
inline void in(int &MAGNUS) { scanf("%d", &MAGNUS); }
inline void out(int MAGNUS) { printf("%d\n", MAGNUS); }
inline void in(int &MAGNUS, int &CLAR) { scanf("%d%d", &MAGNUS, &CLAR); }
inline void out(int MAGNUS, int CLAR) { printf("%d %d\n", MAGNUS, CLAR); }
inline void inl(long long &LIV) { scanf("%lld", &LIV); }
inline void inl(long long &LIV, long long &MART) {
  scanf("%lld%lld", &LIV, &MART);
}
inline void outl(long long LIV) { printf("%lld\n", LIV); }
inline void outl(long long LIV, long long MART) {
  printf("%lld %lld\n", LIV, MART);
}
using namespace std;
pair<long long, long long> node[800005];
pair<long long, long long> dom[200005];
int N;
int binsearch(long long val) {
  int left = 1, right = N, mid;
  while (left <= right) {
    mid = (left + right) / 2;
    if (dom[mid].first < val)
      left = mid + 1;
    else
      right = mid - 1;
  }
  return left;
}
pair<long long, long long> query(int L, int R, int id, int from, int to) {
  if (L > to || R < from) return make_pair(-1, -1);
  if (from <= L && R <= to) return node[id];
  int M = (L + R) / 2, l = 2 * id, r = 2 * id + 1;
  pair<long long, long long> left = query(L, M, l, from, to);
  pair<long long, long long> right = query(M + 1, R, r, from, to);
  if (left.first == -1) return right;
  if (right.first == -1) return left;
  pair<long long, long long> cur = make_pair(0, max(left.second, right.second));
  int nex = binsearch(left.second + 1);
  if (nex > min(R, to)) {
    cur.first = left.first;
    return cur;
  }
  if (nex == M + 1) {
    cur.first = left.first + right.first + dom[M + 1].first - left.second - 1;
    return cur;
  }
  pair<long long, long long> tmp = query(M + 1, R, r, M + 1, nex - 1);
  if (left.second > tmp.second) tmp.first += left.second - tmp.second;
  cur.first = left.first + right.first - tmp.first;
  return cur;
}
void build(int L, int R, int id) {
  if (L == R) {
    node[id] = make_pair(0, dom[L].second);
    return;
  }
  int M = (L + R) / 2, l = 2 * id, r = 2 * id + 1;
  build(L, M, l);
  build(M + 1, R, r);
  node[id].second = max(node[l].second, node[r].second);
  int nex = binsearch(node[l].second + 1);
  if (nex > R) {
    node[id].first = node[l].first;
    return;
  }
  if (nex == M + 1) {
    node[id].first =
        node[l].first + node[r].first + dom[M + 1].first - node[l].second - 1;
    return;
  }
  pair<long long, long long> tmp = query(M + 1, R, r, M + 1, nex - 1);
  if (node[l].second > tmp.second) tmp.first += node[l].second - tmp.second;
  node[id].first = node[l].first + node[r].first - tmp.first;
  return;
}
int main() {
  in(N);
  for (int i = 1; i <= N; i++) {
    int l, r;
    in(l, r);
    dom[i] = make_pair(l, (long long)(l + r - 1));
  }
  build(1, N, 1);
  int Q;
  in(Q);
  for (int q = 1; q <= Q; q++) {
    int from, to;
    in(from, to);
    outl(query(1, N, 1, from, to).first);
  }
  return 0;
}
