#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
const int MM = 998244353;
const long double PI = acos(-1);
long long power(long long b, long long e, long long m) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b % m, e / 2, m) % m;
  return power(b * b % m, e / 2, m);
}
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
template <typename T, typename U>
static inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
static inline void amax(T &x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << '(' << p.first << "," << p.second << ')';
}
const int N = 200005;
int l[N], r[N], lenr[N];
int rnk[N], p[N];
int parent(int i) { return p[i] = (p[i] == i) ? i : parent(p[i]); }
void merge(int x, int y) {
  x = parent(x), y = parent(y);
  if (x == y) return;
  if (r[x] > r[y]) swap(x, y);
  if (r[x] == r[y]) ++r[y];
  p[x] = y;
  amin(l[y], l[x]);
  amax(r[y], r[x]);
  amax(lenr[y], lenr[x]);
}
int px[N], lx[N];
struct Qu {
  int x, y, i;
};
const int MOD = 1000000007;
struct Mint {
  int val;
  Mint(long long v = 0) {
    if (v < 0) v = v % MOD + MOD;
    if (v >= MOD) v %= MOD;
    val = v;
  }
  static int mod_inv(int a, int m = MOD) {
    int g = m, r = a, x = 0, y = 1;
    while (r != 0) {
      int q = g / r;
      g %= r;
      swap(g, r);
      x -= q * y;
      swap(x, y);
    }
    return x < 0 ? x + m : x;
  }
  explicit operator int() const { return val; }
  Mint &operator+=(const Mint &other) {
    val += other.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  Mint &operator-=(const Mint &other) {
    val -= other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return x % m;
    unsigned x_high = x >> 32, x_low = (unsigned)x;
    unsigned quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }
  Mint &operator*=(const Mint &other) {
    val = fast_mod((uint64_t)val * other.val);
    return *this;
  }
  Mint &operator/=(const Mint &other) { return *this *= other.inv(); }
  friend Mint operator+(const Mint &a, const Mint &b) { return Mint(a) += b; }
  friend Mint operator-(const Mint &a, const Mint &b) { return Mint(a) -= b; }
  friend Mint operator*(const Mint &a, const Mint &b) { return Mint(a) *= b; }
  friend Mint operator/(const Mint &a, const Mint &b) { return Mint(a) /= b; }
  Mint &operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }
  Mint &operator--() {
    val = val == 0 ? MOD - 1 : val - 1;
    return *this;
  }
  Mint operator++(int32_t) {
    Mint before = *this;
    ++*this;
    return before;
  }
  Mint operator--(int32_t) {
    Mint before = *this;
    --*this;
    return before;
  }
  Mint operator-() const { return val == 0 ? 0 : MOD - val; }
  bool operator==(const Mint &other) const { return val == other.val; }
  bool operator!=(const Mint &other) const { return val != other.val; }
  Mint inv() const { return mod_inv(val); }
  Mint power(long long p) const {
    assert(p >= 0);
    Mint a = *this, result = 1;
    while (p > 0) {
      if (p & 1) result *= a;
      a *= a;
      p >>= 1;
    }
    return result;
  }
  friend ostream &operator<<(ostream &stream, const Mint &m) {
    return stream << m.val;
  }
  friend istream &operator>>(istream &stream, Mint &m) {
    return stream >> m.val;
  }
};
template <typename T = long long>
struct fenwick {
  T a[N], bit[N];
  int n;
  fenwick() {
    for (int i = 1; i <= N - 2; ++i) a[i] = T(0), bit[i] = T(0);
  }
  void build(int n_) {
    n = n_;
    for (int i = 1; i <= n; ++i)
      for (int j = i; j <= n; j += j & -j) bit[j] += a[i];
  }
  void update(int j, T val) {
    int pos = j;
    for (; j <= n; j += j & -j) bit[j] += val - a[pos];
    a[pos] = val;
  }
  T get(int r) {
    T u = 0;
    for (; r; r -= r & -r) u += bit[r];
    return u;
  }
  T query(int l, int r) { return get(r) - get(l - 1); }
};
fenwick<Mint> fenw;
int ans[N];
int _runtimeTerror_() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> px[i] >> lx[i];
    p[i] = i, r[i] = 0;
    l[i] = r[i] = i;
    lenr[i] = px[i] + lx[i];
  }
  int Q;
  cin >> Q;
  vector<Qu> q(Q);
  int curr = Q - 1;
  for (int i = 0; i < Q; ++i) {
    cin >> q[i].x >> q[i].y;
    q[i].i = i;
  }
  sort(q.begin(), q.end(), [&](Qu a, Qu b) { return a.x < b.x; });
  fenw.build(n);
  for (int i = n - 1; i >= 1; --i) {
    int cur = i;
    fenw.update(cur + 1, px[cur + 1] - lenr[cur]);
    while (cur < n && lenr[parent(cur)] >= px[cur + 1]) {
      fenw.update(cur + 1, 0);
      merge(cur, cur + 1);
      cur = r[parent(cur)];
    }
    fenw.update(cur + 1, px[cur + 1] - lenr[cur]);
    while (curr >= 0 && q[curr].x == i) {
      ans[q[curr].i] = (int)fenw.query(i, q[curr].y);
      --curr;
    }
  }
  for (int i = 0; i < Q; ++i) cout << ans[i] << "\n";
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) _runtimeTerror_();
  return 0;
}
