#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, q, l[N], r[N], del[N], ans[N], rea[N];
pair<pair<int, int>, int> p[N];
int sum[N << 2], tag[N << 2];
stack<int> S;
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  if (a.first.first != b.first.first) return a.first.first > b.first.first;
  return a.first.second < b.first.second;
}
void Updata(int x, int l, int r, int ql, int qr, int del) {
  sum[x] += del * (min(r, qr) - max(l, ql) + 1);
  if (ql <= l && r <= qr) return (void)(tag[x] += del);
  int mid = (l + r) >> 1;
  if (mid >= ql) Updata(x << 1, l, mid, ql, qr, del);
  if (mid < qr) Updata(x << 1 | 1, mid + 1, r, ql, qr, del);
}
int Query(int x, int l, int r, int pos, int add) {
  if (l == r) return (sum[x] + add);
  add += tag[x];
  int mid = (l + r) >> 1;
  if (mid >= pos)
    return Query(x << 1, l, mid, pos, add);
  else
    return Query(x << 1 | 1, mid + 1, r, pos, add);
}
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", &q);
  for (int i = 1; i <= q; i++)
    scanf("%d%d", &p[i].first.first, &p[i].first.second), p[i].second = i;
  sort(p + 1, p + q + 1, cmp);
  int now = 1;
  S.push(n);
  rea[n] = n;
  for (int i = n - 1; i >= 1; i--) {
    if (S.size()) rea[i] = S.top();
    if (r[i] < l[i + 1]) {
      del[i] = l[i + 1] - r[i];
      Updata(1, 1, n, i + 1, n, del[i]);
    } else {
      int d = 0;
      while (S.size()) {
        int x = S.top();
        if (r[x] >= r[i]) break;
        int dx = r[i] - r[x];
        Updata(1, 1, n, rea[x], n, -del[x]);
        rea[i] = rea[x];
        d = max(0, del[x] - dx);
        Updata(1, 1, n, rea[i], n, d);
        S.pop();
      }
      del[i] = d;
    }
    S.push(i);
    while (now <= q && p[now].first.first == i) {
      ans[p[now].second] = Query(1, 1, n, p[now].first.second, 0);
      now++;
    }
  }
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}
