#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} debug1;
template <typename T1, typename T2>
inline ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
const int NN = (1 << 18);
const int inf = numeric_limits<int>::max();
vector<pair<int, int>> adj[NN];
int out[NN], x[NN], len[NN];
int bit[NN], L[NN];
void update(int i, int v) {
  for (i += 5; i < NN; i += i & -i) bit[i] += v;
}
int query(int i) {
  int ans = 0;
  for (i += 5; i > 0; i -= i & -i) ans += bit[i];
  return ans;
}
void solve() {
  int n, m;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> len[i];
    L[i] = i;
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    adj[b].push_back({a, i});
  }
  stack<pair<int, int>> ss;
  ss.push({x[0] + len[0], 0});
  for (int i = 1; i < n; ++i) {
    while (!ss.empty() and ss.top().first < x[i]) {
      int y = ss.top().second;
      int add = x[i] - ss.top().first;
      ss.pop();
      update(L[y], add);
      update(y + 1, -add);
      L[i] = min(L[i], L[y]);
    }
    while (!ss.empty() and ss.top().first <= x[i] + len[i]) {
      int y = ss.top().second;
      ss.pop();
      L[i] = min(L[i], L[y]);
    }
    ss.push({x[i] + len[i], i});
    for (auto tmp : adj[i]) out[tmp.second] = query(tmp.first);
  }
  for (int i = 0; i < m; ++i) cout << out[i] << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
