#include <bits/stdc++.h>
using namespace std;
int get() {
  char c;
  while (c = getchar(), (c < '0' || c > '9') && (c != '-'))
    ;
  bool flag = (c == '-');
  if (flag) c = getchar();
  int x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return flag ? -x : x;
}
void output(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  int len = 0, data[10];
  while (x) {
    data[len++] = x % 10;
    x /= 10;
  }
  if (!len) data[len++] = 0;
  while (len--) putchar(data[len] + 48);
  putchar('\n');
}
const int maxn = 200000;
const int maxsize = 524288;
const int INF = 2000000000;
int p[maxn], len[maxn], a[maxn], b[maxn + 1];
int Left[maxsize], Right[maxsize], Max[maxsize];
int jump[18][maxn], cost[18][maxn];
void build(int p, int l, int r) {
  Left[p] = l;
  Right[p] = r;
  if (l < r) {
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 + 1, mid + 1, r);
  }
}
int getmax(int p, int l, int r) {
  if (Left[p] == l && Right[p] == r) return Max[p];
  int mid = (Left[p] + Right[p]) / 2;
  if (r <= mid) return getmax(p * 2, l, r);
  if (l > mid) return getmax(p * 2 + 1, l, r);
  return max(getmax(p * 2, l, mid), getmax(p * 2 + 1, mid + 1, r));
}
void update(int x, int y) {
  int p = 1;
  while (true) {
    Max[p] = max(Max[p], y);
    if (Left[p] == Right[p]) break;
    p = p * 2 + (x > (Left[p] + Right[p]) / 2);
  }
}
int main() {
  int n = get();
  for (int i = 0; i < n; i++) {
    p[i] = get();
    len[i] = get();
  }
  build(1, 0, n - 1);
  memset(Max, 0, sizeof(Max));
  a[n - 1] = p[n - 1] + len[n - 1];
  update(n - 1, a[n - 1]);
  for (int i = n - 2; i >= 0; i--) {
    if (p[i] + len[i] < p[i + 1])
      a[i] = p[i] + len[i];
    else {
      int tmp = upper_bound(p, p + n, p[i] + len[i]) - p - 1;
      a[i] = max(getmax(1, i + 1, tmp), p[i] + len[i]);
    }
    update(i, a[i]);
  }
  for (int i = 0; i < n; i++) {
    b[i] = upper_bound(p, p + n, a[i]) - p;
    jump[0][i] = b[i];
    if (b[i] < n)
      cost[0][i] = p[b[i]] - a[i];
    else
      cost[0][i] = 0;
  }
  for (int i = 1; i < 18; i++)
    for (int j = 0; j < n; j++) {
      int t = jump[i - 1][j];
      if (t == n) {
        jump[i][j] = n;
        cost[i][j] = cost[i - 1][j];
      } else {
        jump[i][j] = jump[i - 1][t];
        cost[i][j] = cost[i - 1][j] + cost[i - 1][t];
      }
    }
  int q = get();
  while (q--) {
    int x = get() - 1, y = get() - 1;
    int current = 17, sum = 0, ans = INF;
    if (b[x] > y) ans = 0;
    while (current >= 0) {
      int t = jump[current][x];
      if (t == n || b[t] > y)
        ans = min(ans, sum + cost[current][x]);
      else {
        sum += cost[current][x];
        x = jump[current][x];
      }
      current--;
    }
    output(ans);
  }
  return 0;
}
