func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   bool maximize(T &x, const T &y) {     if (x < y)       x = y;     else       return false;     return true;   }   const int N = 5e5 + 10;   int n, q, md;   int dx[N];   int d[N][21];   int query(int x, int y) {     if (d[x][20] < y) return -1;     int ret = 0;     for (int i = 20; i >= 0; i--)       if (d[x][i] < y) {         x = d[x][i];         ret += 1 << i;       }     return ret + 1;   }   int main() {     if (fopen( exam.inp ,  r ))       freopen( exam.inp ,  r , stdin), freopen( exam.out ,  w , stdout);     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) {       int x, y;       scanf( %d%d , &x, &y);       maximize(dx[x], y);       maximize(md, y);     }     for (int i = 1; i <= md; i++) maximize(dx[i], dx[i - 1]);     for (int i = 0; i <= md; i++) d[i][0] = dx[i];     for (int j = 1; j <= 20; j++)       for (int i = 0; i <= md; i++) d[i][j] = d[d[i][j - 1]][j - 1];     while (q--) {       int x, y;       scanf( %d%d , &x, &y);       printf( %d n , query(x, y));     }   }   