func_code_string: #include <bits/stdc++.h>   using namespace std;   int main(int argc, char** argv) {     int n, x, p, min = 0, max = 1000;     cin >> n >> x;     p = x;     for (int i = 0; i < n; i++) {       int a, b;       cin >> a >> b;       if (a < b) {         if ((p >= a) && (p <= b)) {           if (a > min) min = a;           if (b < max) max = b;         } else if (p < a) {           if (a <= max) {             p = a;             if (a > min) min = a;             if (b < max) max = b;           } else {             cout << -1;             return 0;           }         } else if (p > b) {           if (b >= min) {             p = b;             if (a > min) min = a;             if (b < max) max = b;           } else {             cout << -1;             return 0;           }         }       } else {         if ((p >= b) && (p <= a)) {           if (b > min) min = b;           if (a < max) max = a;         } else if (p < b) {           if (b <= max) {             p = b;             if (b > min) min = b;             if (a < max) max = a;           } else {             cout << -1;             return 0;           }         } else if (p > a) {           if (a >= min) {             p = a;             if (b > min) min = b;             if (a < max) max = a;           } else {             cout << -1;             return 0;           }         }       }     }     if ((p - x) >= 0)       cout << p - x;     else       cout << x - p;     return 0;   }   