func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int inf = 0x3f3f3f, maxn = 5e5 + 500;   long long gcd(long long x, long long y) {     if (y == 0)       return x;     else       return gcd(y, x % y);   }   long long ksm(long long a, long long b) {     long long r = 1;     while (b) {       if (b & 1) r = (r * a) % mod;       a = a * a % mod;       b >>= 1;     }     return r;   }   int n, m, f[maxn][25] = {0};   int query(int l, int r) {     int sum = 0;     for (int i = 23; i >= 0; i--) {       if (f[l][i] < r && f[l][i] != 0) {         l = f[l][i];         sum += (1 << i);       }     }     if (f[l][0] < r) return -1;     return sum + 1;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> m;     int max1 = 0;     for (int i = 1; i <= n; i++) {       int l, r;       cin >> l >> r;       f[l][0] = max(f[l][0], r);       max1 = max(r, max1);     }     for (int l = 0; l <= max1; l++)       if (l != 0) f[l][0] = max(f[l][0], max(l, f[l - 1][0]));     for (int j = 1; j <= 23; j++)       for (int l = 0; l <= max1; l++) f[l][j] = f[f[l][j - 1]][j - 1];     for (int i = 1; i <= m; i++) {       int l, r;       cin >> l >> r;       int ans = query(l, r);       cout << ans << endl;     }   }   