#include <bits/stdc++.h>
using namespace std;
int n, p[200020], q[200020], lim, t[200020 * 2], cov[200020 * 8],
    tag[200020 * 8];
int m, x[200020], y[200020], ans[200020];
vector<int> Q[200020];
void download(int k, int l, int r) {
  int mid = (l + r) >> 1;
  cov[k * 2] = t[mid + 1] - t[l];
  cov[k * 2 + 1] = t[r + 1] - t[mid + 1];
  tag[k * 2] = tag[k * 2 + 1] = 1;
  tag[k] = 0;
}
void cover(int k, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    cov[k] = t[r + 1] - t[l];
    tag[k] = 1;
    return;
  }
  if (tag[k]) download(k, l, r);
  int mid = (l + r) >> 1;
  if (L <= mid) cover(k * 2, l, mid, L, R);
  if (R > mid) cover(k * 2 + 1, mid + 1, r, L, R);
  cov[k] = cov[k * 2] + cov[k * 2 + 1];
}
int query(int k, int l, int r, int L, int R) {
  if (L <= l && r <= R) return cov[k];
  if (tag[k]) download(k, l, r);
  int res = 0, mid = (l + r) >> 1;
  if (L <= mid) res += query(k * 2, l, mid, L, R);
  if (R > mid) res += query(k * 2 + 1, mid + 1, r, L, R);
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, l; i <= n; ++i) {
    scanf("%d%d", &p[i], &l);
    t[++lim] = p[i];
    t[++lim] = q[i] = p[i] + l;
  }
  sort(t + 1, t + lim + 1);
  lim = unique(t + 1, t + lim + 1) - t - 1;
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    Q[x[i]].push_back(i);
  }
  for (int i = n, l, r; i; --i) {
    l = lower_bound(t + 1, t + lim + 1, p[i]) - t;
    r = lower_bound(t + 1, t + lim + 1, q[i]) - t - 1;
    cover(1, 1, lim - 1, l, r);
    for (int j = 0; j < Q[i].size(); ++j) {
      r = lower_bound(t + 1, t + lim + 1, q[y[Q[i][j]]]) - t - 1;
      ans[Q[i][j]] = q[y[Q[i][j]]] - p[i] - query(1, 1, lim - 1, l, r);
    }
  }
  for (int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
}
