#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
int seg[4 * int(2e5 + 1000)] = {0}, n, Q, l[int(2e5 + 1000)],
                      r[int(2e5 + 1000)], MaxReachIndex[int(2e5 + 1000)] = {0},
                      MaxReachPosition[int(2e5 + 1000)],
                      mxl[int(2e5 + 1000)] = {0}, x[int(2e5 + 1000)],
                      y[int(2e5 + 1000)];
int Parent[int(2e5 + 1000)][50], Cost[int(2e5 + 1000)][50] = {0};
vector<int> p;
void update(int n, int it, int f, int ind, int SetMaxIndex) {
  if (it == f) {
    seg[n] = SetMaxIndex;
    return;
  }
  int m = (it + f) / 2;
  if (ind <= m)
    update(n * 2, it, m, ind, SetMaxIndex);
  else
    update(n * 2 + 1, m + 1, f, ind, SetMaxIndex);
  seg[n] = max(seg[n * 2 + 1], seg[n * 2]);
}
int Query(int n, int it, int f, int q1, int q2) {
  if (it == q1 && q2 == f) {
    return seg[n];
  }
  int m = (it + f) / 2;
  if (q2 <= m)
    return Query(n * 2, it, m, q1, q2);
  else if (q1 > m)
    return Query(n * 2 + 1, m + 1, f, q1, q2);
  else
    return max(Query(n * 2, it, m, q1, m),
               Query(n * 2 + 1, m + 1, f, m + 1, q2));
}
void BuildParentPart() {
  for (int i = n; i >= 1; i--) {
    if (mxl[i]) {
      Parent[i][0] = MaxReachIndex[i] + 1;
      Cost[i][0] = p[MaxReachIndex[i]] - MaxReachPosition[i];
      for (int j = 1;; j++) {
        if ((1 << j) > mxl[i]) break;
        Parent[i][j] = Parent[Parent[i][j - 1]][j - 1];
        Cost[i][j] = Cost[i][j - 1] + Cost[Parent[i][j - 1]][j - 1];
      }
    }
  }
}
int Query2(int q1, int q2) {
  if (q2 <= MaxReachIndex[q1]) return 0;
  int maxwidth = 0, nn = q1;
  long long int ans = 0;
  for (int maxwidth = 18; maxwidth >= 0; maxwidth--) {
    if ((1 << maxwidth) <= mxl[nn]) {
      if (Parent[nn][maxwidth] <= q2) {
        ans += Cost[nn][maxwidth];
        nn = Parent[nn][maxwidth];
        if (MaxReachIndex[nn] >= q2) return ans;
      }
    }
  }
}
int bns(int q) {
  int it = 0, m, f = n - 1;
  while (it != f) {
    m = (it + f) / 2;
    if (p[m + 1] <= q)
      it = m + 1;
    else
      f = m;
  }
  return f + 1;
}
int WhatTheFuck[4 * int(2e5 + 1000)];
void insert2(int n, int it, int f) {
  if (it == f) {
    WhatTheFuck[n] = p[f - 1] + l[f];
    return;
  }
  int m = (it + f) / 2;
  insert2(n * 2, it, m);
  insert2(n * 2 + 1, m + 1, f);
  WhatTheFuck[n] = max(WhatTheFuck[n * 2], WhatTheFuck[n * 2 + 1]);
}
int fuckyou(int n, int it, int f, int q1, int q2) {
  if (it == q1 && q2 == f) return WhatTheFuck[n];
  int m = (it + f) / 2;
  if (q2 <= m)
    return fuckyou(n * 2, it, m, q1, q2);
  else if (q1 > m)
    return fuckyou(n * 2 + 1, m + 1, f, q1, q2);
  return max(fuckyou(n * 2, it, m, q1, m),
             fuckyou(n * 2 + 1, m + 1, f, m + 1, q2));
}
int main() {
  int q;
  vector<int>::iterator low;
  cin >> n;
  for (int i = int(1); i <= (int)n; i++) {
    scanf("%d", &q);
    ;
    p.push_back(q);
    scanf("%d", &l[i]);
    ;
  }
  insert2(1, 1, n);
  cin >> Q;
  for (int i = int(1); i <= (int)Q; i++) {
    scanf("%d", &x[i]);
    ;
    scanf("%d", &y[i]);
    ;
  }
  update(1, 1, n, n, n);
  MaxReachIndex[n] = n;
  MaxReachPosition[n] = p[n - 1] + l[n];
  mxl[n] = 0;
  for (int i = n - 1; i >= 1; i--) {
    if (p[i - 1] + l[i] < p[i]) {
      MaxReachIndex[i] = i;
      MaxReachPosition[i] = p[i - 1] + l[i];
      update(1, 1, n, i, i);
      if (i < n)
        mxl[i] = mxl[i + 1] + 1;
      else
        mxl[i] = 0;
    } else {
      int tind = bns(p[i - 1] + l[i]);
      int id = Query(1, 1, n, i + 1, tind);
      MaxReachIndex[i] = id;
      MaxReachPosition[i] = fuckyou(1, 1, n, i, id);
      update(1, 1, n, i, id);
      if (id < n)
        mxl[i] = mxl[id + 1] + 1;
      else
        mxl[i] = 0;
    }
  }
  BuildParentPart();
  for (int k = int(1); k <= (int)Q; k++) {
    q = Query2(x[k], y[k]);
    printf("%d\n", q);
  }
  return 0;
}
