#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long _INF = 0xc0c0c0c0c0c0c0c0;
const long long mod = (int)1e9 + 7;
const int N = 2e5 + 100;
int n, Q;
int p[N], l[N];
int x[N], y[N];
long long ans[N];
vector<int> q[N];
long long lz[N << 2], seg[N << 2];
void PushDown(int rt) {
  if (~lz[rt]) {
    lz[rt << 1] = lz[rt << 1 | 1] = lz[rt];
    seg[rt << 1] = seg[rt << 1 | 1] = lz[rt];
    lz[rt] = -1;
  }
}
void PushUp(int rt) { seg[rt] = seg[rt << 1] + seg[rt << 1 | 1]; }
void Updata(int L, int R, long long c, int l, int r, int rt) {
  if (L > R) return;
  if (L <= l && r <= R) {
    lz[rt] = seg[rt] = c;
    return;
  }
  int m = l + r >> 1;
  PushDown(rt);
  if (L <= m) Updata(L, R, c, l, m, rt << 1);
  if (m < R) Updata(L, R, c, m + 1, r, rt << 1 | 1);
  PushUp(rt);
}
long long Query(int L, int R, int l, int r, int rt) {
  if (L > R) return 0;
  if (L <= l && r <= R) return seg[rt];
  long long ret = 0;
  int m = l + r >> 1;
  PushDown(rt);
  if (L <= m) ret += Query(L, R, l, m, rt << 1);
  if (m < R) ret += Query(L, R, m + 1, r, rt << 1 | 1);
  return ret;
}
int Ac() {
  memset(lz, -1, sizeof lz);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &p[i], &l[i]);
  scanf("%d", &Q);
  for (int i = 1; i <= Q; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    q[x[i]].push_back(i);
  }
  for (int i = n; i >= 1; --i) {
    Updata(i, i, inf, 1, n, 1);
    int pos = upper_bound(p + 1, p + 1 + n, p[i] + l[i]) - p - 1;
    if (pos == n) {
      Updata(i + 1, n, 0, 1, n, 1);
    } else {
      Updata(i + 1, pos, 0, 1, n, 1);
      pos++;
      long long dif = p[pos] - p[i] - l[i];
      if (dif < Query(pos, pos, 1, n, 1)) Updata(pos, pos, dif, 1, n, 1);
    }
    for (int id : q[i]) {
      ans[id] = Query(i + 1, y[id], 1, n, 1);
    }
  }
  for (int i = 1; i <= Q; ++i) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}
int main() {
  Ac();
  return 0;
}
