#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int go[N], sum[N << 2], mx[N << 2];
bool fl[N << 2];
int ql, qr, qx, qd, n, q;
int ans[N], tmp[N], pos[N], height[N];
pair<int, int> p[N];
bool cmp(const int &i, const int &j) { return p[i] > p[j]; }
void update1(int x, int l, int r) {
  if (l == r) {
    mx[x] = qd;
  } else {
    if (qx <= ((l + r) >> 1)) update1((x << 1), l, ((l + r) >> 1));
    if (qx > ((l + r) >> 1)) update1((x << 1 | 1), ((l + r) >> 1) + 1, r);
    mx[x] = max(mx[(x << 1)], mx[(x << 1 | 1)]);
  }
}
int query1(int x, int l, int r) {
  if (ql <= l && qr >= r) {
    return mx[x];
  } else {
    int ans = 0;
    if (ql <= ((l + r) >> 1))
      ans = max(ans, query1((x << 1), l, ((l + r) >> 1)));
    if (qr > ((l + r) >> 1))
      ans = max(ans, query1((x << 1 | 1), ((l + r) >> 1) + 1, r));
    return ans;
  }
}
void push(int x, int l, int r) {
  sum[(x << 1)] = sum[(x << 1 | 1)] = 0;
  fl[(x << 1)] = fl[(x << 1 | 1)] = 1;
  fl[x] = 0;
}
void modify(int x, int l, int r) {
  if (l == r) {
    sum[x] = qd;
  } else {
    if (fl[x]) push(x, l, r);
    if (qx <= ((l + r) >> 1))
      modify((x << 1), l, ((l + r) >> 1));
    else
      modify((x << 1 | 1), ((l + r) >> 1) + 1, r);
    sum[x] = sum[(x << 1)] + sum[(x << 1 | 1)];
  }
}
void update(int x, int l, int r) {
  if (ql <= l && qr >= r) {
    fl[x] = 1;
    sum[x] = 0;
  } else {
    if (fl[x]) {
      push(x, l, r);
    }
    if (ql <= ((l + r) >> 1)) update((x << 1), l, ((l + r) >> 1));
    if (qr > ((l + r) >> 1)) update((x << 1 | 1), ((l + r) >> 1) + 1, r);
    sum[x] = sum[(x << 1)] + sum[(x << 1 | 1)];
  }
}
int query(int x, int l, int r) {
  if (ql <= l && qr >= r) {
    return sum[x];
  }
  int ans = 0;
  if (fl[x]) push(x, l, r);
  if (ql <= ((l + r) >> 1)) ans += query((x << 1), l, ((l + r) >> 1));
  if (qr > ((l + r) >> 1)) ans += query((x << 1 | 1), ((l + r) >> 1) + 1, r);
  return ans;
}
void getans() {
  int now = n;
  for (int i = 0; i < (int)(q); i++) {
    int l = p[i].first, r = p[i].second;
    while (now >= l) {
      int tmp = upper_bound(pos + 1, pos + n + 1, pos[now] + height[now]) - pos;
      go[now] = pos[now] + height[now];
      ql = now, qr = tmp - 1;
      if (qr >= ql) {
        go[now] = max(go[now], query1(1, 1, n));
        qx = now, qd = go[now];
        update1(1, 1, n);
      }
      tmp = upper_bound(pos + 1, pos + n + 1, go[now]) - pos;
      ql = now, qr = tmp - 1;
      update(1, 1, n);
      if (tmp <= n) {
        qx = tmp, qd = pos[tmp] - go[now];
        modify(1, 1, n);
      }
      now--;
    }
    int tmp_pos = upper_bound(pos + 1, pos + n + 1, go[l]) - pos;
    if (tmp_pos - 1 >= r) {
      ans[tmp[i]] = 0;
    } else {
      int &res = ans[tmp[i]];
      ql = tmp_pos, qr = r;
      res += query(1, 1, n);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); i++) {
    scanf("%d%d", pos + i, height + i);
  }
  scanf("%d", &q);
  for (int i = 0; i < (int)(q); i++) {
    scanf("%d%d", &p[i].first, &p[i].second);
  }
  for (int i = 0; i < (int)(q); i++) tmp[i] = i;
  sort(tmp, tmp + q, cmp);
  sort(p, p + q);
  reverse(p, p + q);
  getans();
  for (int i = 0; i < (int)(q); i++) printf("%d\n", ans[i]);
  return 0;
}
