#include <bits/stdc++.h>
using namespace std;
const int LOG = 19;
const int N = 200005;
int n, pos[N], h[N];
int R[N], L[N];
int father[LOG + 1][N], cost[LOG + 1][N];
bool checkmax(int &a, int b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
struct Seg {
  int a[N];
  void init() { memset(a, 0, sizeof(a)); }
  void push_up(int x) { a[x] = max(a[x + x], a[x + x + 1]); }
  void modify(int x, int l, int r, int pos, int num) {
    if (l == r) {
      a[x] += num;
      return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid)
      modify(x + x, l, mid, pos, num);
    else
      modify(x + x + 1, mid + 1, r, pos, num);
    push_up(x);
  }
  int query(int x, int l, int r, int L, int R) {
    if (L <= l && r <= R) {
      return a[x];
    }
    int mid = (l + r) >> 1, ans = 0;
    if (L <= mid) checkmax(ans, query(x + x, l, mid, L, R));
    if (R > mid) checkmax(ans, query(x + x + 1, mid + 1, r, L, R));
    return ans;
  }
} now;
void init() {
  now.init();
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &pos[i], &h[i]);
  }
  for (int i = n; i >= 1; --i) {
    int it = upper_bound(pos + 1, pos + n + 1, pos[i] + h[i]) - pos - 1;
    R[i] = pos[i] + h[i];
    if (it > i) {
      checkmax(R[i], now.query(1, 1, n, i + 1, it));
    }
    now.modify(1, 1, n, i, R[i]);
  }
  for (int i = 1; i <= n; ++i) {
    int tmp = upper_bound(pos + 1, pos + n + 1, R[i]) - pos;
    if (tmp > n) {
      father[0][i] = 0;
      cost[0][i] = 0;
      continue;
    }
    father[0][i] = tmp;
    cost[0][i] = pos[tmp] - R[i];
  }
  for (int j = 1; j <= LOG; ++j) {
    for (int i = 1; i <= n; ++i) {
      father[j][i] = father[j - 1][father[j - 1][i]];
      if (father[j][i])
        cost[j][i] = cost[j - 1][i] + cost[j - 1][father[j - 1][i]];
      else
        cost[j][i] = 0;
    }
  }
}
void solve() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int COST = 0, x, y;
    scanf("%d%d", &x, &y);
    for (int i = LOG; i >= 0; --i) {
      if (father[i][x] <= y && father[i][x] != 0) {
        COST += cost[i][x];
        x = father[i][x];
      }
    }
    printf("%d\n", COST);
  }
}
int main() {
  init();
  solve();
  return 0;
}
