#include <bits/stdc++.h>
using namespace std;
int p[200005];
int h[200005];
int nxt[200005][19];
int len[200005][19];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i] >> h[i];
  stack<int> STK;
  for (int i = 1; i <= n; i++) {
    while (STK.size()) {
      int c = STK.top();
      if (p[c] + h[c] >= p[i] + h[i]) break;
      nxt[c][0] = i;
      len[c][0] = max(p[i] - p[c] - h[c], 0);
      STK.pop();
    }
    STK.push(i);
  }
  while (STK.size()) nxt[STK.top()][0] = STK.top(), STK.pop();
  for (int i = 1; i <= 18; i++)
    for (int j = 1; j <= n; j++) {
      nxt[j][i] = nxt[nxt[j][i - 1]][i - 1];
      len[j][i] = len[nxt[j][i - 1]][i - 1] + len[j][i - 1];
    }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    int ans = 0;
    for (int i = 18; ~i; i--)
      if (p[nxt[l][i]] + h[nxt[l][i]] <= p[r]) {
        ans += len[l][i];
        l = nxt[l][i];
      }
    if (p[l] + h[l] < p[r]) ans += len[l][0];
    cout << ans << "\n";
  }
}
