#include <bits/stdc++.h>
using namespace std;
deque<int> deq;
vector<int> quest[200005];
int father[200005], sum[200005], ans[200005], i, j, n, m, x[200005], y[200005],
    p[200005], q[200005];
struct Bar {
  int l, r;
} a[200005];
int find(int x) { return father[x] == x ? x : father[x] = find(father[x]); }
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) father[i] = i;
  for (i = 1; i <= n; a[i].r += a[i].l, i++) scanf("%d%d", &a[i].l, &a[i].r);
  scanf("%d", &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    quest[x[i]].push_back(i);
  }
  for (i = n; i; --i) {
    p[i] = a[i].l, q[i] = a[i].r;
    while (!deq.empty() && p[deq.front()] <= q[i]) {
      q[i] = max(q[i], q[deq.front()]);
      father[find(deq.front())] = i;
      deq.pop_front();
    }
    sum[i] = (deq.empty()) ? 0 : sum[deq.front()] + p[deq.front()] - q[i];
    deq.push_front(i);
    for (j = 0; j < quest[i].size(); ++j) {
      int t = quest[i][j];
      ans[t] = sum[i] - sum[find(y[t])];
    }
  }
  for (i = 1; i <= m; ++i) printf("%d\n", ans[i]);
  return 0;
}
