#include <bits/stdc++.h>   using namespace std;   const int maxn = 50100;   vector<int> v;   int n, k, st, x;   int nextchild[maxn], value[maxn];   void get_rand() {     int arr[n + 1];     for (int i = 0; i < n; i++) {       arr[i] = i + 1;     }     srand(time(0));     random_shuffle(arr, arr + n);     for (int i = 0; i < k; i++) {       v.push_back(arr[i]);     }   }   int main() {     cin >> n >> st >> x;     k = min(n, 1000);     get_rand();     memset(nextchild, 0, sizeof(nextchild));     memset(value, -1, sizeof(value));     cout <<  ?   << st <<   n ;     fflush(stdout);     cin >> value[st] >> nextchild[st];     int maxind = st;     int maxval = value[st];     for (int i : v) {       cout <<  ?   << i <<   n ;       fflush(stdout);       cin >> value[i] >> nextchild[i];       if (value[i] <= x && value[i] > maxval) {         maxval = value[i];         maxind = i;       }     }     int curr = maxind;     int answ = maxind;     while (true) {       cout <<  ?   << curr <<   n ;       fflush(stdout);       cin >> value[curr] >> nextchild[curr];       if (value[curr] >= x || nextchild[curr] == -1)         break;       else         curr = nextchild[curr];     }     if (value[curr] >= x) {       cout <<  !   << value[curr] <<   n ;       fflush(stdout);     } else {       cout <<  ! -1 n ;       fflush(stdout);     }     return 0;   }   