#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline istream& operator>>(istream& fin, pair<T1, T2>& pr) {
  fin >> pr.first >> pr.second;
  return fin;
}
template <class T0, class T1, class T2>
inline istream& operator>>(istream& fin, tuple<T0, T1, T2>& t) {
  fin >> get<0>(t) >> get<1>(t) >> get<2>(t);
  return fin;
}
template <class T>
inline istream& operator>>(istream& fin, vector<T>& a) {
  if (!a.size()) {
    size_t n;
    fin >> n;
    a.resize(n);
  }
  for (auto& u : a) fin >> u;
  return fin;
}
int build_tree(const int x, const int y, const int l, const int r,
               const size_t id, vector<int>& tree, const vector<int>& leaf) {
  if (y < leaf[l] + 1 || leaf[r] < x + 1) return 0;
  int inc = 0;
  if (x < leaf[l] + 1 && leaf[r] < y + 1)
    inc = (leaf[r] - leaf[l]) - tree[id];
  else if (tree[id] != leaf[r] - leaf[l]) {
    const auto mid = (l + r) >> 1;
    inc = build_tree(x, y, l, mid, 2 * id + 1, tree, leaf) +
          build_tree(x, y, mid, r, 2 * id + 2, tree, leaf);
  }
  tree[id] += inc;
  return inc;
}
int query_tree(const int x, const int y, const int l, const int r,
               const size_t id, const vector<int>& tree,
               const vector<int>& leaf) {
  if (y < leaf[l] + 1 || leaf[r] < x + 1) return 0;
  if (x < leaf[l] + 1 && leaf[r] < y + 1) return tree[id];
  if (tree[id] == leaf[r] - leaf[l]) return min(y, leaf[r]) - max(x, leaf[l]);
  const auto mid = (l + r) >> 1;
  return query_tree(x, y, l, mid, 2 * id + 1, tree, leaf) +
         query_tree(x, y, mid, r, 2 * id + 2, tree, leaf);
}
void e500() {
  vector<pair<int, int> > a;
  vector<pair<size_t, size_t> > query;
  cin >> a >> query;
  vector<int> leaf;
  leaf.reserve(a.size());
  for (auto& pr : a) {
    leaf.push_back(pr.first);
    leaf.push_back(pr.first + pr.second);
    pr.second += pr.first;
  }
  sort(begin(leaf), end(leaf));
  leaf.erase(unique(begin(leaf), end(leaf)), end(leaf));
  ;
  vector<size_t> idx(query.size());
  iota(begin(idx), end(idx), 0);
  const auto comp = [&query](const size_t i, const size_t j) {
    return query[i] > query[j];
  };
  sort(begin(idx), end(idx), comp);
  vector<int> soln(query.size());
  vector<int> tree(leaf.size() * 4);
  auto iter = a.rbegin();
  for (const auto i : idx) {
    const auto x = a[query[i].first - 1].first;
    const auto y = a[query[i].second - 1].first;
    for (; iter != a.rend() && x < iter->first + 1; ++iter)
      build_tree(iter->first, iter->second, 0, leaf.size() - 1, 0, tree, leaf);
    soln[i] = y - x - query_tree(x, y, 0, leaf.size() - 1, 0, tree, leaf);
  }
  copy(begin(soln), end(soln), ostream_iterator<int>(cout, "\n"));
}
int main(const int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  e500();
  return EXIT_SUCCESS;
}
