#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;
}
size_t build_tree(const size_t x, const size_t y, const size_t id,
                  const size_t l, const size_t r, vector<size_t>& tree,
                  const vector<size_t>& leaf) {
  if (y < leaf[l] + 1 || leaf[r] < x + 1 || leaf[l] + tree[id] == leaf[r])
    return tree[id];
  if (x < leaf[l] + 1 && leaf[r] < y + 1) return tree[id] = leaf[r] - leaf[l];
  const auto i = (l + r) >> 1;
  const auto acc = build_tree(x, y, 2 * id + 1, l, i, tree, leaf) +
                   build_tree(x, y, 2 * id + 2, i, r, tree, leaf);
  return tree[id] = max(tree[id], acc);
}
size_t query_tree(const size_t x, const size_t y, const size_t id,
                  const size_t l, const size_t r, const vector<size_t>& tree,
                  const vector<size_t>& leaf) {
  if (y < leaf[l] + 1 || leaf[r] < x + 1 || !tree[id]) return 0;
  if (x < leaf[l] + 1 && leaf[r] < y + 1) return tree[id];
  if (leaf[l] + tree[id] == leaf[r]) return min(leaf[r], y) - max(leaf[l], x);
  const auto i = (l + r) >> 1;
  return query_tree(x, y, 2 * id + 1, l, i, tree, leaf) +
         query_tree(x, y, 2 * id + 2, i, r, tree, leaf);
}
void e500() {
  vector<pair<size_t, size_t>> dom, query;
  cin >> dom >> query;
  const auto n = dom.size();
  for (auto& pr : query)
    pr = {dom[pr.first - 1].first, dom[pr.second - 1].first};
  const auto m = query.size();
  vector<size_t> ord(m, 0);
  iota(begin(ord), end(ord), 0);
  {
    const auto comp = [&query](const size_t i, const size_t j) {
      return query[j].first < query[i].first;
    };
    sort(begin(ord), end(ord), comp);
  }
  vector<size_t> leaf;
  leaf.reserve(2 * n);
  for (const auto& pr : dom)
    leaf.push_back(pr.first), leaf.push_back(pr.first + pr.second);
  sort(begin(leaf), end(leaf));
  leaf.erase(unique(begin(leaf), end(leaf)), end(leaf));
  {
    const auto comp = [](const pair<size_t, size_t>& a,
                         const pair<size_t, size_t>& b) {
      return b.first < a.first;
    };
    sort(begin(dom), end(dom), comp);
  }
  vector<size_t> tree(4 * leaf.size() + 1, 0);
  const size_t last = leaf.size() - 1;
  vector<size_t> soln(m);
  auto iter = begin(dom);
  for (const auto i : ord) {
    for (; iter != end(dom) && query[i].first < iter->first + 1; ++iter)
      build_tree(iter->first, iter->first + iter->second, 0, 0, last, tree,
                 leaf);
    soln[i] =
        query[i].second - query[i].first -
        query_tree(query[i].first, query[i].second, 0, 0, last, tree, leaf);
  }
  copy(begin(soln), end(soln), ostream_iterator<size_t>(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;
}
