#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000005;
int n, query;
pair<int, int> a[200005];
vector<pair<int, int> > g[200005];
int last[200005];
pair<int, int> f[200005][25];
queue<int> q;
int d[2][1000005];
int upper(int first) {
  int l = 1, r = n + 1, mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (a[mid].first <= first)
      l = mid + 1;
    else
      r = mid;
  }
  return l;
}
void update(int type, int k, int p, int q, int first, int second, int z) {
  if (p > second || q < first || p > q) return;
  if (first <= p && q <= second) {
    d[type][k] = z;
    return;
  }
  update(type, 2 * k, p, (p + q) / 2, first, second, z);
  update(type, 2 * k + 1, (p + q) / 2 + 1, q, first, second, z);
  d[type][k] = max(d[type][2 * k], d[type][2 * k + 1]);
}
int get(int type, int k, int p, int q, int first, int second) {
  if (p > second || q < first || p > q) return -INF;
  if (first <= p && q <= second) {
    return d[type][k];
  }
  return max(get(type, 2 * k, p, (p + q) / 2, first, second),
             get(type, 2 * k + 1, (p + q) / 2 + 1, q, first, second));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    update(0, 1, 1, n, i, i, a[i].first + a[i].second);
  }
  sort(a + 1, a + 1 + n);
  a[n + 1] = pair<int, int>(INF, INF);
  last[n] = n;
  update(1, 1, 1, n, n, n, n);
  for (int i = n - 1; i >= 1; i--) {
    int first = upper(a[i].first + a[i].second);
    int cost;
    if (first - 1 != i) {
      last[i] = get(1, 1, 1, n, i + 1, first - 1);
      cost = max(a[i].first + a[i].second, get(0, 1, 1, n, i + 1, last[i]));
    } else {
      last[i] = i;
      cost = a[i].first + a[i].second;
    }
    if (last[i] < n) {
      int second = last[i] + 1;
      g[second].push_back(pair<int, int>(a[second].first - cost, i));
    } else
      g[n].push_back(pair<int, int>(0, i));
    update(1, 1, 1, n, i, i, last[i]);
  }
  q.push(n);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 20; j++) {
      f[i][j].first = 0;
      f[i][j].second = 0;
    }
  }
  while (!q.empty()) {
    int first = q.front();
    q.pop();
    for (int i = 1; i <= 20; i++) {
      if (f[first][i - 1].first == 0) break;
      f[first][i].first = f[f[first][i - 1].first][i - 1].first;
      f[first][i].second =
          f[first][i - 1].second + f[f[first][i - 1].first][i - 1].second;
    }
    for (int i = 0; i < (int)g[first].size(); i++) {
      int z = g[first][i].first, second = g[first][i].second;
      f[second][0].first = first;
      f[second][0].second = z;
      q.push(second);
    }
  }
  scanf("%d", &query);
  while (query--) {
    int first, second;
    scanf("%d%d", &first, &second);
    int cost = 0;
    for (int i = 20; i >= 0; i--) {
      if (f[first][i].first == 0 || f[first][i].first >= second) continue;
      cost += f[first][i].second;
      first = f[first][i].first;
    }
    if (f[first][0].first == second) cost += f[first][0].second;
    printf("%d\n", cost);
  }
  return 0;
}
