#include <bits/stdc++.h>   struct node {     int x, l;   } a[200005];   int skip[200005][25];   int mx[200005];   long long f[200005][25];   inline int read() {     register int x = 0, f = 1;     register char s = getchar();     while (s >  9  || s <  0 ) {       if (s ==  - ) f = -1;       s = getchar();     }     while (s >=  0  && s <=  9 ) {       x = x * 10 + s -  0 ;       s = getchar();     }     return x * f;   }   inline int max(const int &x, const int &y) { return x > y ? x : y; }   int main() {     int n = read();     for (register int i = 1; i <= n; ++i) {       a[i].x = read();       a[i].l = read();     }     for (register int i = n - 1; i >= 1; --i) {       int cur = i + 1;       mx[i] = a[i].x + a[i].l;       while (cur && a[i].x + a[i].l >= a[cur].x) {         mx[i] = max(mx[i], mx[cur]);         cur = skip[cur][0];       }       skip[i][0] = cur;       f[i][0] = a[cur].x - mx[i];     }     for (register int i = 1; i <= 20; ++i) {       for (register int x = 1; x <= n; ++x) {         f[x][i] = f[x][i - 1] + f[skip[x][i - 1]][i - 1];         skip[x][i] = skip[skip[x][i - 1]][i - 1];       }     }     int Q = read();     while (Q--) {       int l = read(), r = read();       if (skip[l][0] > r) {         printf( 0 n );       } else {         long long ans = 0;         for (register int i = 20; i >= 0; --i) {           if (skip[l][i] && skip[l][i] <= r) {             ans += f[l][i];             l = skip[l][i];           }         }         printf( %lld n , ans);       }     }     return 0;   }   