#include <bits/stdc++.h>
using namespace std;
int c;
void read(int &number) {
  bool negative = false;
  number = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
  if (negative) number *= -1;
}
template <typename T>
void read(T &object) {
  if (typeid(object).name()[0] == 'i')
    read(object);
  else
    cin >> object;
}
template <typename... Args>
void read(Args &...args) {
  ((read(args)), ...);
}
template <typename... Args>
void print(Args... args) {
  ((cout << args), ...);
}
template <typename... Args>
void eprint(Args... args) {
  ((cerr << args), ...);
}
const int N = 200005, M = 21, INF = 2000000007;
int n, x[N], y[N], r[N], rcost[N], m, X[N], Y[N], jump[N][M], cost[N][M];
struct segt {
  int sz;
  int arr[4 * N];
  void init() {
    for (sz = 1; sz <= n; sz <<= 1)
      ;
    memset(arr, 0, sizeof(arr));
  }
  void set(int x, int y) {
    x += sz - 1;
    while (x) {
      arr[x] = max(arr[x], y);
      x >>= 1;
    }
  }
  int query(int x, int y, int i, int l, int r) {
    if (x <= l && r <= y) return arr[i];
    if (x >= r || y <= l) return 0;
    int mid = (l + r) >> 1;
    return max(query(x, y, i << 1, l, mid), query(x, y, (i << 1) | 1, mid, r));
  }
} seg;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  read(n);
  for (int i = 1; i <= n; i++) read(x[i], y[i]);
  r[n + 1] = n + 1;
  read(m);
  for (int i = 1; i <= m; i++) read(X[i], Y[i]);
  seg.init();
  for (int i = n; i >= 1; i--) {
    int pos = upper_bound(x + 1, x + 1 + n, x[i] + y[i]) - x - 1;
    int lst = max(x[i] + y[i], seg.query(i - 1, pos, 1, 0, seg.sz));
    r[i] = upper_bound(x + 1, x + 1 + n, lst) - x;
    rcost[i] = max(x[r[i]] - lst, 0);
    seg.set(i, lst);
  }
  for (int i = 1; i <= n + 1; i++) {
    jump[i][0] = r[i];
    cost[i][0] = rcost[i];
  }
  for (int j = 1; j < M; j++) {
    for (int i = 1; i <= n + 1; i++) {
      int pos = jump[i][j - 1];
      jump[i][j] = jump[pos][j - 1];
      cost[i][j] = cost[i][j - 1] + cost[pos][j - 1];
    }
  }
  for (int i = 1; i <= m; i++) {
    int pos = X[i];
    int ans = 0;
    for (int j = M - 1; j >= 0; j--) {
      if (jump[pos][j] <= Y[i]) {
        ans += cost[pos][j];
        pos = jump[pos][j];
      }
    }
    print(ans, "\n");
  }
  return 0;
}
