#include <bits/stdc++.h>
using namespace std;
deque<int> deq;
int n, len[200009], pos[200009], m;
vector<pair<int, int> > query[200009];
int ans[200009];
struct Node {
  int l, r, sum;
} tree[200009 * 4];
void build(int u, int l, int r) {
  tree[u].l = l;
  tree[u].r = r;
  tree[u].sum = 0;
  if (l == r) return;
  int mid = l + r >> 1;
  build(u * 2, l, mid);
  build(u * 2 + 1, mid + 1, r);
}
void add(int u, int l, int r, int val) {
  if (l > r) return;
  if (tree[u].l == l && tree[u].r == r) {
    tree[u].sum += val;
    return;
  }
  int mid = tree[u].l + tree[u].r >> 1;
  if (r <= mid)
    add(u * 2, l, r, val);
  else if (l > mid)
    add(u * 2 + 1, l, r, val);
  else
    add(u * 2, l, mid, val), add(u * 2 + 1, mid + 1, r, val);
}
void push(int u) {
  tree[u * 2].sum += tree[u].sum;
  tree[u * 2 + 1].sum += tree[u].sum;
  tree[u].sum = 0;
}
int find_(int u, int x) {
  if (tree[u].l == tree[u].r) return tree[u].sum;
  push(u);
  int mid = tree[u].l + tree[u].r >> 1;
  if (x <= mid)
    return find_(u * 2, x);
  else
    return find_(u * 2 + 1, x);
}
int main() {
  cin >> n;
  for (int i = (1); i <= (n); i++) cin >> pos[i] >> len[i];
  cin >> m;
  for (int i = (1); i <= (m); i++) {
    int u, v;
    cin >> u >> v;
    query[v].push_back(pair<int, int>(u, i));
  }
  build(1, 1, n);
  for (int k = (2); k <= (n); k++) {
    while (!deq.empty()) {
      int id = deq.back();
      if (len[k - 1] + pos[k - 1] >= len[id] + pos[id])
        deq.pop_back();
      else
        break;
    }
    bool fff = 0;
    deq.push_back(k - 1);
    while (!deq.empty()) {
      int id = deq.back();
      if (len[id] + pos[id] >= pos[k]) break;
      deq.pop_back();
      int lastid = 0, tmp = pos[k] - len[id] - pos[id];
      if (!deq.empty()) lastid = deq.back();
      add(1, lastid + 1, id, tmp);
      len[id] += tmp;
      fff = 1;
    }
    if (fff) deq.push_back(k - 1);
    for (int i = 0; i < (query[k].size()); i++) {
      int lastid = query[k][i].first;
      int tmp = query[k][i].second;
      ans[tmp] = find_(1, lastid);
    }
  }
  for (int i = (1); i <= (m); i++) cout << ans[i] << endl;
}
