#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct section {
  int l, r, id;
} x[N];
vector<int> b[N];
int qx[N], qy[N], se_l[N], se_r[N], fa[N], sum[N], ans[N];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int main() {
  int len, n, m;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i].l, &len);
    x[i].r = x[i].l + len;
    fa[i] = i;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &qx[i], &qy[i]);
    b[qx[i]].push_back(i);
  }
  deque<int> que;
  for (int i = n; i > 0; i--) {
    se_l[i] = x[i].l, se_r[i] = x[i].r;
    while (!que.empty() && se_l[que.front()] <= se_r[i]) {
      se_r[i] = max(se_r[i], se_r[que.front()]);
      fa[find(que.front())] = i;
      que.pop_front();
    }
    if (!que.empty())
      sum[i] = sum[que.front()] + se_l[que.front()] - se_r[i];
    else
      sum[i] = 0;
    que.push_front(i);
    for (int j = 0; j < b[i].size(); j++) {
      int id = b[i][j];
      int tmp = qy[id];
      ans[id] = sum[i] - sum[find(tmp)];
    }
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
}
