#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << el;
	cout.flush();
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	return a.fi < b.fi;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n, false);
  	ll idx;
  	// Random query first 1000 elements
  	for(ll i = 0; i < 1000; i++){
	  	do{
	  		idx = rng() % n;
	  	}while(isV[idx]);
	  	query(idx+1);
	  	isV[val] = true;
	  	ar.pb(mp(val, nxt));
  	}
  	sort(ar.begin(), ar.end(), cmp);
  	idx = lb(ar.begin(), ar.end(), mp(x,0), cmp) - ar.begin();
  	val = ar[idx].fi;
  	nxt = ar[idx].se;
  	for(ll i = 0; i < 1000 && val < x && nxt != -1; i++){
  		if(isV[nxt])
  			break;
  		query(nxt);
  	}
  	if(val < x || nxt == -1)
  		cout << "! -1" << el;
  	else
  		cout << "! " << val << el;
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	if (a.fi != b.fi)
		return a.fi < b.fi;
	return a.se > b.se;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n+1, false);
  	ll idx;
  	query(st);
  	isV[st] = true;
  	// cout << "? " << st << endl;
  	// cin >> val >> nxt;
  	ar.pb(mp(val, nxt));
  	// Random query first 999 elements
  	for(ll i = 0; i < 1499; i++){
	  	do{
	  		idx = (rng() % n) + 1;
	  	}while(isV[idx]);
	  	query(idx);
	  	// cout << "? " << idx << endl;
	  	// cin >> val >> nxt;
	  	isV[idx] = true;
	  	ar.pb(mp(val, idx));
  	}

  	// sort(ar.begin(), ar.end(), cmp);
  	sort(ar.begin(), ar.end())

  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		else if(i.fi > x)
  			break;
  		val = i.fi;
  		nxt = i.se;
  	}

  	for(ll i = 0; i < 500; i++){
  		// if(isV[nxt])
  		// 	break;
  		query(nxt);
  		// cout << "? " << nxt << endl;
  		// cin >> val >> nxt;
  		if(val >= x){
  			cout << "! " << val << el;
  			break;
  		}
  		if(nxt == -1){
  			cout << "! -1" << el;
  			break;
  		}
  	}
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	if (a.fi != b.fi)
		return a.fi < b.fi;
	return a.se > b.se;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{

  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n+1, false);
  	ll idx;
  	// cout << "? " << st << endl;
  	// cin >> val >> nxt;
  	query(st);
  	isV[st] = true;
  	ar.pb(mp(val, nxt));

  	for(ll i = 0; i < 1499; i++){
  		do{
  			idx = (rng() % n)+1;
  		}while(isV[idx]);
  		isV[idx] = true;
  		// cout << "? " << idx << endl;
  		// cin >> val >> nxt;
  		query(idx);
  		ar.pb(mp(val, idx));
  	}

  	sort(ar.begin(), ar.end());
  	nxt = st;
  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		if(i.fi < x)
  			nxt = i.se;
  	}

  	for(ll i = 0; i < 500; i++){
  		query(nxt);
  		if(val >= x){
  			cout << "! " << val << endl;
  			exit(0);
  		}
  		if(nxt == -1)
  			break;
  		// cout << "? " << nxt << endl;
  		// cin >> val >> nxt;
  	}
  	cout << "! -1" << endl;
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << el;
	cout.flush();
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	return a.fi < b.fi;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = ub(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx >= n)
  		cout << "! " << -1 << el;
  	else{
  		cout << "! " << ar[idx] << el;
  	}
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n, false);
  	ll idx;
  	// Random query first 1000 elements
  	for(ll i = 0; i < 1000; i++){
	  	do{
	  		idx = rng() % n;
	  	}while(isV[idx]);
	  	query(idx+1);
	  	isV[val] = true;
	  	ar.pb(mp(val, nxt));
  	}
  	sort(ar.begin(), ar.end(), cmp);
  	idx = lb(ar.begin(), ar.end(), mp(x,0), cmp) - ar.begin();
  	val = ar[idx].fi;
  	nxt = ar[idx].se;
  	for(ll i = 0; i < 1000 && val < x && nxt != -1; i++){
  		if(isV[nxt])
  			break;
  		query(nxt);
  	}
  	if(val < x || nxt == -1)
  		cout << "! -1" << el;
  	else
  		cout << "! " << val << el;
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val, nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

	ll n, st, x;
	cin >> n >> st >> x;
	if(n <= 2000){
		vector<ll> ar(n);
		for(ll i = 0; i < n; i++){
			query(i+1);
			ar[i] = val;
		}
		sort(ar.begin(), ar.end());
		auto iter = lb(ar.begin(), ar.end(), x);
		if(iter == ar.end())
			cout << "! -1" << endl;
		else
			cout << "! " << ar[iter - ar.begin()] << endl;
	}
	else{
		vector<pair<ll, ll>> ar;
		vector<bool> isV(n+1, false);
		pair<ll, ll> ptr;
		query(st);
		isV[st] = true;
		ptr = mp(val, nxt);
		ar.pb(ptr);
		ll idx;
		for(ll i = 0; i < 1499; i++){
			do{
				idx = (rng()%n) + 1;
			}while(isV[idx]);
			isV[idx] = false;
			query(idx);
			ar.pb(mp(val, nxt));
		}

		sort(ar.begin(), ar.end());

		for(auto p : ar){
			if(p.fi == x){
				cout << "! " << x << endl;
				exit(0);
			}
			if(p.fi > x)
				break;
			ptr.fi = p.fi;
			ptr.se = p.se;
		}
		val = ptr.fi;
		nxt = ptr.se;
		for(ll i = 0; i < 500; i++){
			query(nxt);
			if(val >= x){
				cout << "! " << val << endl;
				exit(0);
			}
			if(nxt == -1)
				cout << "! -1" << endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	if (a.fi != b.fi)
		return a.fi < b.fi;
	return a.se > b.se;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{

  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n+1, false);
  	ll idx;
  	// cout << "? " << st << endl;
  	// cin >> val >> nxt;
  	query(st);
  	isV[st] = true;
  	ar.pb(mp(val, nxt));
    ll tmp = val;
  	for(ll i = 0; i < 1499; i++){
  		do{
  			idx = (rng() % n)+1;
  		}while(isV[idx]);
  		isV[idx] = true;
  		// cout << "? " << idx << endl;
  		// cin >> val >> nxt;
  		query(idx);
  		ar.pb(mp(val, nxt));
  	}

  	sort(ar.begin(), ar.end());
  	nxt = st;
    val = tmp;
  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		if(i.fi > x)
        break;
      val = i.fi;
  		nxt = i.se;
  	}

  	for(ll i = 0; i < 500; i++){
  		if(val >= x){
  			cout << "! " << val << endl;
  			exit(0);
  		}
  		if(nxt == -1)
  			break;
  		query(nxt);
  		// cout << "? " << nxt << endl;
  		// cin >> val >> nxt;
  	}
  	cout << "! -1" << endl;
  }
  cout.flush();
	return 0;
}


    #include <bits/stdc++.h>
    #include <stdio.h>

    using namespace std;

    #define int long long

    bool codejam = 0;

    typedef long long li;
    typedef long double ld;

    void solve();

    int32_t main () {
    	// ios_base::sync_with_stdio(false);
    	// cin.tie(nullptr);
    	cout << fixed << setprecision(20);
    	#ifdef LOCAL
    		// freopen("input.txt", "r", stdin);
    	#endif
    	int t = 1;
    	// cin >> t;
    	int tt = t;
    	while (t--) {
    		if (codejam) cout << "Case #" << tt - t << ": ";
    		solve();
    	}
    	return 0;
    }
    int n, strt, x;
    void solve() {
    	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    	cin >> n >> strt >> x;
    	int mag = 1499;
    	vector<pair<int, int>> save;
    	cout << "? " << strt << endl;
    	int val, nxt;
    	cin >> val >> nxt;
    	save.push_back({val, nxt});
    	for (int i = 1; i <= mag; i += 1) {
    		int lol = (rng() % n) + 1;
    		cout << "? " << lol << endl;
    		cin >> val >> nxt;
    		save.push_back({val, lol});
    	}
    	sort(save.begin(), save.end());
    	for (auto i: save) {
    		if (i.first == x) {
    			cout << "! " << i.first << endl;
    			return;
    		}
    		if (i.first < x) {
    			strt = i.second;
    		}
    	}
    	for (int i = 1; i <= 499; i += 1) {
    		cout << "? " << strt << endl;
    		cin >> val >> nxt;
    		if (val >= x) {
    			cout << "! " << val << endl;
    			return;
    		}
    		if (nxt == -1) {
    			cout << "! " << -1 << endl;
    			return;
    		}
    		strt = nxt;
    	}
    	cout << "! " << -1 << endl;
    }


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << el;
	cout.flush();
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	return a.fi < b.fi;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	while(ar[idx] < x){
  		if(idx >= n){
  			cout << "! -1" << el;
  			exit(0);
  		}
  		idx++;
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n, false);
  	ll idx;
  	// Random query first 1000 elements
  	for(ll i = 0; i < 1000; i++){
	  	do{
	  		idx = rng() % n;
	  	}while(isV[idx]);
	  	query(idx+1);
	  	isV[val] = true;
	  	ar.pb(mp(val, nxt));
  	}
  	sort(ar.begin(), ar.end(), cmp);
  	idx = lb(ar.begin(), ar.end(), mp(x,0), cmp) - ar.begin();
  	val = ar[idx].fi;
  	nxt = ar[idx].se;
  	for(ll i = 0; i < 1000 && val < x && nxt != -1; i++){
  		if(isV[nxt])
  			break;
  		query(nxt);
  	}
  	if(val < x || nxt == -1)
  		cout << "! -1" << el;
  	else
  		cout << "! " << val << el;
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << el;
	cout.flush();
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	return a.fi < b.fi;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n, false);
  	ll idx;
  	query(st);
  	isV[st-1] = true;
  	ar.pb(mp(val, nxt));
  	// Random query first 999 elements
  	for(ll i = 0; i < 1499; i++){
	  	do{
	  		idx = rng() % n;
	  	}while(isV[idx]);
	  	query(idx+1);
	  	isV[idx] = true;
	  	ar.pb(mp(val, nxt));
  	}
  	sort(ar.begin(), ar.end(), cmp);
  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		else if(i.fi < x)
	  		nxt = i.se;
  	}
  	for(ll i = 0; i < 500; i++){
  		// if(isV[nxt])
  		// 	break;
  		query(nxt);
  		if(val >= x){
  			cout << "! " << val << el;
  			break;
  		}
  		if(nxt == -1){
  			cout << "! -1" << el;
  			break;
  		}
  	}
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << el;
	cout.flush();
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	return a.fi < b.fi;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n, false);
  	ll idx;
  	query(st);
  	isV[st-1] = true;
  	ar.pb(mp(val, nxt));
  	// Random query first 999 elements
  	for(ll i = 0; i < 1499; i++){
	  	do{
	  		idx = rng() % n;
	  	}while(isV[idx]);
	  	query(idx+1);
	  	isV[idx] = true;
	  	ar.pb(mp(val, nxt));
  	}
  	sort(ar.begin(), ar.end(), cmp);
  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		else if(i.fi < x)
	  		nxt = i.se;
  	}
  	for(ll i = 0; i < 500; i++){
  		// if(isV[nxt])
  		// 	break;
  		if(val >= x){
  			cout << "! " << val << el;
  			break;
  		}
  		if(nxt == -1){
  			cout << "! -1" << el;
  			break;
  		}
  		query(nxt);
  	}
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	if (a.fi != b.fi)
		return a.fi < b.fi;
	return a.se > b.se;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	// vector<pair<ll, ll>> ar;
  	// vector<bool> isV(n+1, false);
  	// ll idx;
  	// query(st);
  	// isV[st] = true;
  	// // cout << "? " << st << endl;
  	// // cin >> val >> nxt;
  	// ar.pb(mp(val, nxt));
  	// // Random query first 999 elements
  	// for(ll i = 0; i < 1499; i++){
	  // 	do{
	  // 		idx = (rng() % n) + 1;
	  // 	}while(isV[idx]);
	  // 	query(idx);
	  // 	// cout << "? " << idx << endl;
	  // 	// cin >> val >> nxt;
	  // 	isV[idx] = true;
	  // 	ar.pb(mp(val, idx));
  	// }

  	// // sort(ar.begin(), ar.end(), cmp);
  	// sort(ar.begin(), ar.end());

  	// for(auto i : ar){
  	// 	if(i.fi == x){
  	// 		cout << "! " << x << endl;
  	// 		exit(0);
  	// 	}
  	// 	else if(i.fi > x)
  	// 		break;
  	// 	val = i.fi;
  	// 	nxt = i.se;
  	// }

  	// for(ll i = 0; i < 500; i++){
  	// 	// if(isV[nxt])
  	// 	// 	break;
  	// 	query(nxt);
  	// 	// cout << "? " << nxt << endl;
  	// 	// cin >> val >> nxt;
  	// 	if(val >= x){
  	// 		cout << "! " << val << el;
  	// 		break;
  	// 	}
  	// 	if(nxt == -1){
  	// 		cout << "! -1" << el;
  	// 		break;
  	// 	}
  	// }

  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n+1, false);
  	ll idx;
  	cout << "? " << st << endl;
  	cin >> val >> nxt;
  	ar.pb(mp(val, nxt));

  	for(ll i = 0; i < 1499; i++){
  		do{
  			idx = (rng() % n)+1;
  		}while(isV[idx]);
  		cout << "? " << idx << endl;
  		cin >> val >> nxt;
  		ar.pb(mp(val, idx));
  	}

  	sort(ar.begin(), ar.end());

  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		if(i.fi > x)
  			break;
  		val = i.fi;
  		nxt = i.se;
  	}

  	for(ll i = 0; i < 500; i++){
  		cout << "? " << nxt << endl;
  		cin >> val >> nxt;
  		if(val >= x){
  			cout << "! " << val << endl;
  			exit(0);
  		}
  		if(nxt == -1)
  			break;
  	}
  	cout << "! -1" << endl;
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << el;
	cout.flush();
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	return a.fi < b.fi;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n, false);
  	ll idx;
  	query(st);
  	isV[st-1] = true;
  	ar.pb(mp(val, nxt));
  	// Random query first 999 elements
  	for(ll i = 0; i < 1499; i++){
	  	do{
	  		idx = rng() % n;
	  	}while(isV[idx]);
	  	query(idx+1);
	  	isV[idx] = true;
	  	ar.pb(mp(val, nxt+1));
  	}
  	sort(ar.begin(), ar.end(), cmp);
  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		else if(i.fi > x)
  			break;
  		nxt = i.se;
  		val = i.se;
  	}
  	for(ll i = 0; i < 500; i++){
  		// if(isV[nxt])
  		// 	break;
  		if(val >= x){
  			cout << "! " << val << el;
  			break;
  		}
  		if(nxt == -1){
  			cout << "! -1" << el;
  			break;
  		}
  		query(nxt);
  	}
  }
  cout.flush();
	return 0;
}


    #include <bits/stdc++.h>

    typedef int64_t ll;
    typedef uint64_t ull;
    typedef double db;

    using namespace std;

    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define lb lower_bound
    #define ub upper_bound
    #define prs(n) cout << fixed << setprecision(n)
    #define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
    #define el "\n"
    #define sp " "

    // RNG - for sum fun
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

    // Combination calculate
    ll nCr(ll n, ll r){
    	// The fomular:
    	// n! / (r! * (n-r)!)
    	// Complexity: O(r)
    	ll tmp = n-r;
    	for(ll i = n-1; i > tmp; i--)
    		n *= i;

    	for(ll i = r-1; i > 1; i--)
    		r *= i;
    	return n/r;
    }

    ll val;
    ll nxt;

    void query(ll idx){
    	cout << "? " << idx << el;
    	cout.flush();
    	cin >> val >> nxt;
    	if(val == -1 && nxt == -1)
    		exit(0);
    }

    bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
    	return a.fi < b.fi;
    }

    int main(int argc, char const *argv[]) {
    	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
    	setvbuf(stdin, 0, _IONBF, 0);
    	setvbuf(stdout, 0, _IONBF, 0);
    	setvbuf(stderr, 0, _IONBF, 0);
    #ifdef LOCAL_PROJECT
      freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    #endif

      ll st, n, x;
      cin >> n >> st >> x;
      if(n <= 2000){
      	vector<ll> ar;
      	for(ll i = 0; i < n; i++){
      		query(i+1);
      		ar.pb(val);
      	}
      	sort(ar.begin(), ar.end());
      	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
      	if(idx == n){
      		cout << "! -1" << el;
    			cout.flush();
    			exit(0);
      	}
      	while(ar[idx] < x){
      		idx++;
      		if(idx >= n){
      			cout << "! -1" << el;
      			cout.flush();
      			exit(0);
      		}
      	}
      	cout << "! " << ar[idx] << el;
      }
      else{
      	vector<pair<ll, ll>> ar;
      	vector<bool> isV(n, false);
      	ll idx;
      	query(st);
      	isV[st-1] = true;
      	ar.pb(mp(val, nxt));
      	// Random query first 999 elements
      	for(ll i = 0; i < 1499; i++){
    	  	do{
    	  		idx = rng() % n;
    	  	}while(isV[idx]);
    	  	query(idx+1);
    	  	isV[idx] = true;
    	  	ar.pb(mp(val, nxt));
      	}
      	sort(ar.begin(), ar.end(), cmp);
      	for(auto i : ar){
      		if(i.fi == x){
      			cout << "! " << x << endl;
      			exit(0);
      		}
      		else if(i.fi > x)
      			break;
      		val = i.fi;
      		nxt = i.se;
      	}
      	for(ll i = 0; i < 500; i++){
      		// if(isV[nxt])
      		// 	break;
      		query(nxt);
      		if(val >= x){
      			cout << "! " << val << el;
      			break;
      		}
      		if(nxt == -1){
      			cout << "! -1" << el;
      			break;
      		}
      	}
      }
      cout.flush();
    	return 0;
    }


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	if (a.fi != b.fi)
		return a.fi < b.fi;
	return a.se > b.se;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n+1, false);
  	ll idx;
  	// query(st);
  	isV[st] = true;
  	cout << "? " << st << endl;
  	cin >> val >> nxt;
  	ar.pb(mp(val, nxt));
  	// Random query first 999 elements
  	for(ll i = 0; i < 1499; i++){
	  	do{
	  		idx = (rng() % n) + 1;
	  	}while(isV[idx]);
	  	// query(idx);
	  	cout << "? " << idx << endl;
	  	isV[idx] = true;
	  	cin >> val >> nxt;
	  	ar.pb(mp(val, nxt));
  	}

  	// sort(ar.begin(), ar.end(), cmp);
  	sort(ar.begin(), ar.end());

  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		else if(i.fi > x)
  			break;
  		val = i.fi;
  		nxt = i.se;
  	}

  	for(ll i = 0; i < 500; i++){
  		// if(isV[nxt])
  		// 	break;
  		// query(nxt);
  		cout << "? " << nxt << endl;
  		cin >> val >> nxt;
  		if(val >= x){
  			cout << "! " << val << el;
  			break;
  		}
  		if(nxt == -1){
  			cout << "! -1" << el;
  			break;
  		}
  	}
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	if (a.fi != b.fi)
		return a.fi < b.fi;
	return a.se > b.se;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n+1, false);
  	ll idx;
  	query(st);
  	isV[st] = true;
  	ar.pb(mp(val, nxt));
  	// Random query first 999 elements
  	for(ll i = 0; i < 1499; i++){
	  	do{
	  		idx = (rng() % n) + 1;
	  	}while(isV[idx]);
	  	query(idx);
	  	isV[idx] = true;
	  	ar.pb(mp(val, nxt));
  	}

  	sort(ar.begin(), ar.end(), cmp);

  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		else if(i.fi > x)
  			break;
  		val = i.fi;
  		nxt = i.se;
  	}

  	for(ll i = 0; i < 500; i++){
  		// if(isV[nxt])
  		// 	break;
  		query(nxt);
  		if(val >= x){
  			cout << "! " << val << el;
  			break;
  		}
  		if(nxt == -1){
  			cout << "! -1" << el;
  			break;
  		}
  	}
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	if (a.fi != b.fi)
		return a.fi < b.fi;
	return a.se > b.se;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	// vector<pair<ll, ll>> ar;
  	// vector<bool> isV(n+1, false);
  	// ll idx;
  	// query(st);
  	// isV[st] = true;
  	// // cout << "? " << st << endl;
  	// // cin >> val >> nxt;
  	// ar.pb(mp(val, nxt));
  	// // Random query first 999 elements
  	// for(ll i = 0; i < 1499; i++){
	  // 	do{
	  // 		idx = (rng() % n) + 1;
	  // 	}while(isV[idx]);
	  // 	query(idx);
	  // 	// cout << "? " << idx << endl;
	  // 	// cin >> val >> nxt;
	  // 	isV[idx] = true;
	  // 	ar.pb(mp(val, idx));
  	// }

  	// // sort(ar.begin(), ar.end(), cmp);
  	// sort(ar.begin(), ar.end());

  	// for(auto i : ar){
  	// 	if(i.fi == x){
  	// 		cout << "! " << x << endl;
  	// 		exit(0);
  	// 	}
  	// 	else if(i.fi > x)
  	// 		break;
  	// 	val = i.fi;
  	// 	nxt = i.se;
  	// }

  	// for(ll i = 0; i < 500; i++){
  	// 	// if(isV[nxt])
  	// 	// 	break;
  	// 	query(nxt);
  	// 	// cout << "? " << nxt << endl;
  	// 	// cin >> val >> nxt;
  	// 	if(val >= x){
  	// 		cout << "! " << val << el;
  	// 		break;
  	// 	}
  	// 	if(nxt == -1){
  	// 		cout << "! -1" << el;
  	// 		break;
  	// 	}
  	// }

  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n+1, false);
  	ll idx;
  	cout << "? " << st << endl;
  	cin >> val >> nxt;
  	ar.pb(mp(val, nxt));

  	for(ll i = 0; i < 1499; i++){
  		// do{
  			idx = (rng() % n)+1;
  		// }while(isV[idx]);
  		cout << "? " << idx << endl;
  		cin >> val >> nxt;
  		ar.pb(mp(val, idx));
  	}

  	sort(ar.begin(), ar.end());

  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		if(i.fi > x)
  			break;
  		val = i.fi;
  		nxt = i.se;
  	}

  	for(ll i = 0; i < 500; i++){
  		cout << "? " << nxt << endl;
  		cin >> val >> nxt;
  		if(val >= x){
  			cout << "! " << val << endl;
  			exit(0);
  		}
  		if(nxt == -1)
  			break;
  	}
  	cout << "! -1" << endl;
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << el;
	cout.flush();
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	return a.fi < b.fi;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n, false);
  	ll idx;
  	query(st);
  	isV[st] = true;
  	ar.pb(mp(val, nxt));
  	// Random query first 999 elements
  	for(ll i = 0; i < 999; i++){
	  	do{
	  		idx = rng() % n;
	  	}while(isV[idx]);
	  	query(idx+1);
	  	isV[idx] = true;
	  	ar.pb(mp(val, nxt));
  	}
  	sort(ar.begin(), ar.end(), cmp);
  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		else if(i.fi > x)
  			break;
  		nxt = i.se;
  	}
  	for(ll i = 0; i < 1000; i++){
  		// if(isV[nxt])
  		// 	break;
  		query(nxt);
  		if(val >= x){
  			cout << "! " << val << el;
  			break;
  		}
  		if(nxt == -1){
  			cout << "! -1" << el;
  			break;
  		}
  	}
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val, nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

	ll n, st, x;
	cin >> n >> st >> x;
	if(n <= 2000){
		vector<ll> ar(n);
		for(ll i = 0; i < n; i++){
			query(i+1);
			ar[i] = val;
		}
		sort(ar.begin(), ar.end());
		auto iter = lb(ar.begin(), ar.end(), x);
		if(iter == ar.end())
			cout << "! -1" << endl;
		else
			cout << "! " << ar[iter - ar.begin()] << endl;
	}
	else{
		vector<pair<ll, ll>> ar;
		vector<bool> isV(n+1, false);
		ll pos = st;
		query(st);
		isV[st] = true;
		ll startV = val;
		ar.pb(mp(val, nxt));
		ll idx;
		for(ll i = 0; i < 1499; i++){
			do{
				idx = (rng()%n) + 1;
			}while(isV[idx]);
			isV[idx] = false;
			query(idx);
			ar.pb(mp(val, idx));
		}

		sort(ar.begin(), ar.end());

		for(auto p : ar){
			if(p.fi == x){
				cout << "! " << x << endl;
				exit(0);
			}
			if(p.fi > x)
				break;
			startV = p.fi;
			pos = p.se;
		}
		val = startV;
		nxt = pos;
		for(ll i = 0; i < 500; i++){
			query(nxt);
			if(val >= x){
				cout << "! " << val << endl;
				exit(0);
			}
			if(nxt == -1)
				cout << "! -1" << endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	if (a.fi != b.fi)
		return a.fi < b.fi;
	return a.se > b.se;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{
  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n+1, false);
  	ll idx;
  	query(st);
  	isV[st] = true;
  	// cout << "? " << st << endl;
  	// cin >> val >> nxt;
  	ar.pb(mp(val, nxt));
  	// Random query first 999 elements
  	for(ll i = 0; i < 1499; i++){
	  	do{
	  		idx = (rng() % n) + 1;
	  	}while(isV[idx]);
	  	query(idx);
	  	// cout << "? " << idx << endl;
	  	// cin >> val >> nxt;
	  	isV[idx] = true;
	  	ar.pb(mp(val, idx));
  	}

  	// sort(ar.begin(), ar.end(), cmp);
  	sort(ar.begin(), ar.end());

  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		else if(i.fi > x)
  			break;
  		val = i.fi;
  		nxt = i.se;
  	}

  	for(ll i = 0; i < 500; i++){
  		// if(isV[nxt])
  		// 	break;
  		query(nxt);
  		// cout << "? " << nxt << endl;
  		// cin >> val >> nxt;
  		if(val >= x){
  			cout << "! " << val << el;
  			break;
  		}
  		if(nxt == -1){
  			cout << "! -1" << el;
  			break;
  		}
  	}
  }
  cout.flush();
	return 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define prs(n) cout << fixed << setprecision(n)
#define DEBUG(val) cerr << "#####\nRunning on Line " << __LINE__ << " in Function " << 	__FUNCTION__ << el << val << "#####";
#define el "\n"
#define sp " "

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// Combination calculate
ll nCr(ll n, ll r){
	// The fomular:
	// n! / (r! * (n-r)!)
	// Complexity: O(r)
	ll tmp = n-r;
	for(ll i = n-1; i > tmp; i--)
		n *= i;

	for(ll i = r-1; i > 1; i--)
		r *= i;
	return n/r;
}

ll val;
ll nxt;

void query(ll idx){
	cout << "? " << idx << endl;
	cin >> val >> nxt;
	if(val == -1 && nxt == -1)
		exit(0);
}

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
	if (a.fi != b.fi)
		return a.fi < b.fi;
	return a.se > b.se;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	setvbuf(stdin, 0, _IONBF, 0);
	setvbuf(stdout, 0, _IONBF, 0);
	setvbuf(stderr, 0, _IONBF, 0);
#ifdef LOCAL_PROJECT
  freopen("in", "r", stdin);
//freopen("out", "w", stdout);
#endif

  ll st, n, x;
  cin >> n >> st >> x;
  if(n <= 2000){
  	vector<ll> ar;
  	for(ll i = 0; i < n; i++){
  		query(i+1);
  		ar.pb(val);
  	}
  	sort(ar.begin(), ar.end());
  	ll idx = lb(ar.begin(), ar.end(), x) - ar.begin();
  	if(idx == n){
  		cout << "! -1" << el;
			cout.flush();
			exit(0);
  	}
  	while(ar[idx] < x){
  		idx++;
  		if(idx >= n){
  			cout << "! -1" << el;
  			cout.flush();
  			exit(0);
  		}
  	}
  	cout << "! " << ar[idx] << el;
  }
  else{

  	vector<pair<ll, ll>> ar;
  	vector<bool> isV(n+1, false);
  	ll idx;
  	// cout << "? " << st << endl;
  	// cin >> val >> nxt;
  	query(st);
  	isV[st] = true;
  	ar.pb(mp(val, nxt));

  	for(ll i = 0; i < 1499; i++){
  		do{
  			idx = (rng() % n)+1;
  		}while(isV[idx]);
  		isV[idx] = true;
  		// cout << "? " << idx << endl;
  		// cin >> val >> nxt;
  		query(idx);
  		ar.pb(mp(val, nxt));
  	}

  	sort(ar.begin(), ar.end());
  	nxt = st;
  	for(auto i : ar){
  		if(i.fi == x){
  			cout << "! " << x << endl;
  			exit(0);
  		}
  		if(i.fi > x)
  			break;
  		val = i.fi;
  		nxt = i.se;
  	}

  	for(ll i = 0; i < 500; i++){
  		if(val >= x){
  			cout << "! " << val << endl;
  			exit(0);
  		}
  		if(nxt == -1)
  			break;
  		query(nxt);
  		// cout << "? " << nxt << endl;
  		// cin >> val >> nxt;
  	}
  	cout << "! -1" << endl;
  }
  cout.flush();
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#include<random>
#include<ctime>
std::mt19937 rnd(time(0));

int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	int n,start,x;
	cin>>n>>start>>x;
	int y;
	int ans=-1;
	int t,id=start;
	int z;
	repd(i,1,999)
	{
	    y=rnd()%n+1;
	    cout<<"? "<<y<<endl;
	    cin>>t>>z;
	    if(t>ans&&t<x)
        {
            ans=t;
            id=z;
        }
	}
	repd(i,1,999)
	{
	    if(id==-1)
        {
            break;
        }
        cout<<"? "<<id<<endl;
        cin>>t>>z;
        if(t>=x)
        {
            cout<<"! "<<t<<endl;
            return 0;
        }
        id=z;
	}
	cout<<"! -1"<<endl;
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();}
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9')
{*p = *p * 10 + ch - '0';}}}


#define _CRT_SECURE_NO_WARNINGS
void Solve(); int main() { Solve(); }
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <bitset>
#include <stdio.h>
#include <string.h>

using namespace std;
//#define int long long
#define endl '\n'
#define fib(i, n) for (int i = n; i >= 0; i--)
#define fi(i,a,b) for(int i = (a); i < (b); i++)
#define MAX 1 << 10
#define pb push_back
#define finish(x)  return cout << x << endl, 0;
typedef long long ll;
const int MAXINT = 2147483640;
const ll MAXLL = 9223372036854775800LL;
const ll MAXN = 1123456;
const ll MOD = 1123456769;

int f[MAXN], x, val, now, ans = -1;
void step(int num) {
	f[num] = 1;
	cout << "? " << num << endl;
	cin >> val >> num;
	if (val == -1) exit(0);
	if (val <= x && val > ans) now = num, ans = val;
}

void Solve()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	//    cin.tie(0);
	srand(time(0));
	int n, y, kol, i, j;
	cin >> n >> now >> x;
	step(now);
	for (i = 1; i < min(1000, n); i++) {
		y = rand() * rand() % (n - i) + 1;
		kol = 0;
		for (j = 1; j <= n; j++) if (!f[j]) if (++kol == y) step(j);
	}
	val = ans;
	while (val < x && now > 0) step(now);
	if (val < x) val = -1;
	cout << "! " << val << endl;

}


#define _CRT_SECURE_NO_WARNINGS
void Solve(); int main() { Solve(); }
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <bitset>
#include <stdio.h>
#include <string.h>

using namespace std;
#define int long long
#define endl '\n'
#define fib(i, n) for (int i = n; i >= 0; i--)
#define fi(i,a,b) for(int i = (a); i < (b); i++)
#define MAX 1 << 10
#define pb push_back
#define finish(x)  return cout << x << endl, 0;

vector<pair<int, int> > v;

void Solve()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	int n, st, x;
	scanf("%d%d%d", &n, &st, &x);
	srand(time(0));
	for (int i = 0; i<1000; i++)
	{
		int tmp = (rand()*rand()) % n + 1;
		printf("? %d\n", tmp);
		fflush(stdout);
		int val, ne;
		scanf("%d%d", &val, &ne);
		v.push_back({ val,tmp });
	}
	sort(v.begin(), v.end());
	int ind = st;
	for (auto p : v)
	{
		if (p.first<x)
			ind = p.second;
	}
	while (1)
	{
		printf("? %d\n", ind);
		fflush(stdout);
		int val, ne;
		scanf("%d%d", &val, &ne);
		if (val >= x)
		{
			printf("! %d\n", val);
			fflush(stdout);
			return;
		}
		if (ne == -1)
		{
			printf("! -1");
			fflush(stdout);
			return;
		}
		ind = ne;
	}

}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int n, st, x, val = -1, cur;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;

	for (ll t = 0; t < 1000; t++){
		ll pos = t *(1000000009LL) % n * 1000000007 % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val < d) {
			val = d;
			cur = w;
		}
	}
	while (~cur && val < x) {
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << "-1" << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int n, st, x, val = -1, cur;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;
	cur = st;
	for (ll t = 0; t < 1000; t++){
		ll pos = rand()%n+1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d < x && val < d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 999; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << -1 << endl;
}


#include<cstdio>
int n, s, x, cnt, q[1000], maxi = -1;
int main() {
    scanf("%d%d%d", &n, &s, &x);
    for (int i = 0; i < 1000; i++) q[i] = i*(1000000009LL) % n * 1000000007 % n + 1;

    int v, nxt;
    for (int i = 0; i < 1000; i++) {
        printf("? %d\n", q[i]);
        fflush(stdout);
        scanf("%d %d", &v, &nxt);
        if (v <= x && maxi < v) maxi = v, s = nxt;
    }
    while (~s && maxi < x) {
        printf("? %d\n", s);
        fflush(stdout);
        scanf("%d %d", &v, &nxt);
        maxi = v;
        s = nxt;
    }
    printf("! %d", maxi < x ? -1 : maxi);
    fflush(stdout);
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int n, st, x, val = -1, cur;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;

	for (ll t = 0; t < 1000; t++){
		int pos = t *(1000000009LL) % n * 1000000007 % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val < d) {
			val = d;
			cur = w;
		}
	}
	while (~cur && val < x) {
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << "! -1" << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int n, st, x, val, cur;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;
	for (ll t = 0; t < 998; t++){
		ll pos = t*1000000009LL%n*1000000007%n+1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val < d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 998; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << -1 << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	int n, st, x, val, cur;
	cin >> n >> st >> x;

	cout<< "? " << st << endl;
	cin >> val >> cur ;

	for (int t = 0; t < 998; t++){
		int pos = rand() % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val > d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 998; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << -1 << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int n, st, x, val, cur;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;
	cur = st;
	for (ll t = 0; t < 998; t++){
		ll pos = rand()%n+1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d < x && val < d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 998; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << -1 << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int n, st, x, val = -1, cur;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;

	for (ll t = 0; t < 1000; t++){
		ll pos = t *(1000000009LL) % n * 1000000007 % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val < d) {
			val = d;
			cur = w;
		}
	}
	while (~cur && val < x) {
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << "! -1" << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	int n, st, x, val, cur = st;
	cin >> n >> st >> x;

	cout<< "? " << st << endl;
	cin >> val;

	for (int t = 0; t < 998; t++){
		int pos = rand() % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val > d) {
			val = d;
			cur = pos;
		}
	}

	for (int t = 0; t < 998; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << -1 << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	int n, st, x, val, cur;
	cin >> n >> st >> x;

	cout<< "? " << st << endl;
	cin >> val >> cur ;

	for (ll t = 0; t < 998; t++){
		ll pos = t*1000000009LL%n*1000000007%n+1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val > d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 998; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << -1 << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	int n, st, x, val, cur;
	cin >> n >> st >> x;

	cout<< "? " << st << endl;
	cin >> val >> cur ;

	for (ll t = 0; t < 998; t++){
		ll pos = t*1000000009LL%n*1000000007%n+1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val < d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 998; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << -1 << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	int n, st, x, val, cur = st;
	cin >> n >> st >> x;

	cout<< "? " << st << endl;
	cin >> val;

	for (int t = 0; t < 998; t++){
		int pos = rand() % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val > d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 998; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << -1 << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int n, st, x, val = -1, cur;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;

	for (ll t = 0; t < 999; t++){
		int pos = rand() % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d < x && val < d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 999; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << "! -1" << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	int n, st, x, val, cur = st;
	cin >> n >> st >> x;

	cout<< "? " << st;
	cin >> val;

	for (int t = 0; t < 998; t++){
		int pos = rand() % n + 1;
		cout<< "? " << pos;
		int d, w;
		cin >> d >> w;
		if (d <= x && val > d) {
			val = d;
			cur = pos;
		}
	}

	for (int t = 0; t < 998; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val; else cout << -1;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	int n, st, x, val, cur = st;
	cin >> n >> st >> x;

	cout<< " ?" << st;
	cin >> val;

	for (int t = 0; t < 998; t++){
		int pos = rand() % n + 1;
		cout<< " ?" << pos;
		int d, w;
		cin >> d >> w;
		if (d <= x && val > d) {
			val = d;
			cur = pos;
		}
	}

	for (int t = 0; t < 998; t++){
		if (val >= x || cur == -1) break;
		cout<< " ?" << cur;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val; else cout << -1;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int n, st, x, val = -1, cur;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;

	cur = st;

	for (int t = 0; t < 999; t++){
		int pos = t*(1000000009LL) % n * 1000000007 % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val < d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 999; t++) {
		if (val >= x || cur == -1) break;
    	cout << "? " << cur << endl;
    	int d, w;
		cin >> d >> w;
    	val = d;
    	cur = w;
    }

	if (val >= x) cout << "! " << val << endl; else cout << "! -1" << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int n, st, x, val = -1, cur;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;
	cur = st;
	for (ll t = 0; t < 999; t++){
		int pos = t*(1000000009LL) % n * 1000000007 % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val < d) {
			val = d;
			cur = w;
		}
	}

	while (~cur && val < x) {
        cout << "? " << cur << endl;
        int d, w;
		cin >> d >> w;
        val = d;
        cur = w;
    }

	if (val >= x) cout << "! " << val << endl; else cout << "! -1" << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int n, st, x, val, cur;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;

	for (ll t = 0; t < 999; t++){
		int pos = rand() % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d < x && val < d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 999; t++){
		if (val >= x || cur == -1) break;
		cout<< "? " << cur << endl;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << "! " << val << endl; else cout << "! -1" << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	int n, st, x, val, cur = st;
	cin >> n >> st >> x;

	cout<< " ?" << st;
	cin >> val;

	for (int t = 0; t < 998; t++){
		int pos = rand() % n + 1;
		cout<< " ?" << pos;
		int d, w;
		cin >> d >> w;
		if (d <= x && val > d) {
			val = d;
			cur = pos;
		}
	}

	for (int t = 0; t < 998; t++){
		if (val >= x || cur == -1) break;
		cout<< " ?" << cur;
		int d, w;
		cin >> d >> w;
		val = d;
		cur = w;
	}

	if (val >= x) cout << val; else cout << -1;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int N = 100005;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

int n, st, x, val = -1, cur;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	srand(time(NULL));
	cin >> n >> st >> x;

	cur = st;

	for (int t = 0; t < 999; t++){
		int pos = t*(1000000009LL) % n * 1000000007 % n + 1;
		cout<< "? " << pos << endl;
		int d, w;
		cin >> d >> w;
		if (d <= x && val < d) {
			val = d;
			cur = w;
		}
	}

	for (int t = 0; t < 999; t++) {
		if (val >= x || cur == -1) break;
        cout << "? " << cur << endl;
        int d, w;
		cin >> d >> w;
        val = d;
        cur = w;
    }

	if (val >= x) cout << "! " << val << endl; else cout << "! -1" << endl;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
          res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
vector<int>vo;
int main()
{
  #if !ONLINE_JUDGE
  //freopen("in.txt","r",stdin);
  #endif
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);

  int n,start,x;cin>>n>>start>>x;
  rep(i,n)vo.pb(i+1);
  random_shuffle(all(vo));

  const int quer=min(n,650);

  int nnode=start;
  for(int i=1;i<=quer){
    cout<<"? "<<nnode<<endl;
    int v,nex;cin>>v>>nex;
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    nnode=nex;
  }

  int index=-1,maxi=-INF;
  for(int i=1;i<=quer;i++){
    cout<<"? "<<vo[i-1]<<endl;
    int v,nex;cin>>v>>nex;
    if(v==x){cout<<"! "<<v<<endl;exit(0);}
    if(v<x and v>maxi)
      maxi=v,index=vo[i-1];
  }

  int nnode=index;
  while(nnode!=-1){
    cout<<"? "<<nnode<<endl;
    int v,nex;cin>>v>>nex;
    if(v==-1 and nex==-1)exit(0);
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    nnode=nex;
  }
  cout<<"! -1"<<endl;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
          res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
vector<int>vo;
int main()
{
  #if !ONLINE_JUDGE
  //freopen("in.txt","r",stdin);
  #endif
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);
  srand(time(0));

  int n,start,x;cin>>n>>start>>x;
  rep(i,n)vo.pb(i+1);
  random_shuffle(all(vo));

  const int quer=min(n,660);

  int nnode=start;
  for(int i=1;i<=quer;i++){
    cout<<"? "<<nnode<<endl;
    int v,nex;cin>>v>>nex;
    if(v==-1 and nex==-1)exit(0);
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    nnode=nex;
  }

  int index=-1,maxi=-INF;
  for(int i=1;i<=quer;i++){
    cout<<"? "<<vo[i-1]<<endl;
    int v,nex;cin>>v>>nex;
    if(v==-1 and nex==-1)exit(0);
    if(v==x){cout<<"! "<<v<<endl;exit(0);}
    if(v<x and v>maxi)
      maxi=v,index=vo[i-1];
  }

  nnode=index;
  while(nnode!=-1){
    cout<<"? "<<nnode<<endl;
    int v,nex;cin>>v>>nex;
    if(v==-1 and nex==-1)exit(0);
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    nnode=nex;
  }
  cout<<"! -1"<<endl;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
          res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
struct nott{
  int i,next,value;
  nott(int i,int next,int value):i(i),next(next),value(value){}
  bool operator==(nott &arg){
    return i==arg.i;
  }
  bool operator<(nott &arg){
    return value<arg.value;
  }
};

vector<nott>h;
vector<int>vo;
int main()
{
  #if !ONLINE_JUDGE
  //freopen("in.txt","r",stdin);
  #endif
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);

  int n,start,x;cin>>n>>start>>x;
  rep(i,n)vo.pb(i+1);
  random_shuffle(all(vo));

  for(int i=1;i<=min(n,1500);i++){
    cout<<"? "<<vo[i-1]<<endl;
    int v,nex;cin>>v>>nex;
    h.pb(nott(vo[i-1],nex,v));
  }
  sort(all(h));
  int maxi=-INF,mini=INF,miniindex=-1,maxiindex=-1;
  for(int i=0;i<min(n,1500);i++){
    if(h[i].value<x and h[i].value>maxi)
      maxi=h[i].value,maxiindex=h[i].i;
    else if(h[i].value>x and h[i].value<mini)
      mini=h[i].value,miniindex=h[i].i;
    else if(h[i].value==x)cout<<"! "<<x<<endl;
  }
  swap(miniindex,maxiindex);
  if(mini==INF){cout<<"! -1"<<endl;exit(0);}
  if(maxi=-INF)miniindex=start;

  int val;
  while(1){
    cout<<"? "<<miniindex<<endl;
    int v,nex;cin>>v>>nex;
    if(v==-1 and nex==-1)exit(0);
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    if(miniindex==maxiindex)break;
    miniindex=nex;
  }
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
          res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
struct nott{
  int i,next,value;
  nott(int i,int next,int value):i(i),next(next),value(value){}
  bool operator==(nott &arg){
    return i==arg.i;
  }
  bool operator<(nott &arg){
    return value<arg.value;
  }
};

vector<nott>h;
vector<int>vo;
int main()
{
  #if !ONLINE_JUDGE
  //freopen("in.txt","r",stdin);
  #endif
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);

  int n,start,x;cin>>n>>start>>x;
  rep(i,n)vo.pb(i+1);
  random_shuffle(all(vo));

  for(int i=1;i<=min(n,1000);i++){
    cout<<"? "<<vo[i-1]<<endl;
    int v,nex;cin>>v>>nex;
    h.pb(nott(vo[i-1],nex,v));
  }
  sort(all(h));
  int maxi=-INF,mini=INF,miniindex=-1,maxiindex=-1;
  for(int i=0;i<min(n,1000);i++){
    if(h[i].value<x and h[i].value>maxi)
      maxi=h[i].value,maxiindex=h[i].i;
    else if(h[i].value>x and h[i].value<mini)
      mini=h[i].value,miniindex=h[i].i;
    else if(h[i].value==x)cout<<"! "<<x<<endl;
  }
  swap(miniindex,maxiindex);
  if(mini==INF){cout<<"! -1"<<endl;exit(0);}
  if(maxi=-INF)miniindex=start;

  int val;
  while(1){
    cout<<"? "<<miniindex<<endl;
    int v,nex;cin>>v>>nex;
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    if(miniindex==maxiindex)break;
    miniindex=nex;
  }
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
          res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
vector<int>vo;
int main()
{
  #if !ONLINE_JUDGE
  //freopen("in.txt","r",stdin);
  #endif
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);

  int n,start,x;cin>>n>>start>>x;
  rep(i,n)vo.pb(i+1);
  random_shuffle(all(vo));

  const int quer=min(n,650);

  int nnode=start;
  for(int i=1;i<=quer;i++){
    cout<<"? "<<nnode<<endl;
    int v,nex;cin>>v>>nex;
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    nnode=nex;
  }

  int index=-1,maxi=-INF;
  for(int i=1;i<=quer;i++){
    cout<<"? "<<vo[i-1]<<endl;
    int v,nex;cin>>v>>nex;
    if(v==x){cout<<"! "<<v<<endl;exit(0);}
    if(v<x and v>maxi)
      maxi=v,index=vo[i-1];
  }

  nnode=index;
  while(nnode!=-1){
    cout<<"? "<<nnode<<endl;
    int v,nex;cin>>v>>nex;
    if(v==-1 and nex==-1)exit(0);
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    nnode=nex;
  }
  cout<<"! -1"<<endl;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
          res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
vector<int>vo;
int main()
{
  #if !ONLINE_JUDGE
  //freopen("in.txt","r",stdin);
  #endif
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);

  int n,start,x;cin>>n>>start>>x;
  rep(i,n)vo.pb(i+1);
  random_shuffle(all(vo));

  const int quer=min(n,650);

  int node=start;
  for(int i=1;i<=quer){
    cout<<"? "<<node<<endl;
    int v,nex;cin>>v>>nex;
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    node=nex;
  }

  int index=-1,maxi=-INF;
  for(int i=1;i<=quer;i++){
    cout<<"? "<<vo[i-1]<<endl;
    int v,nex;cin>>v>>nex;
    if(v==x){cout<<"! "<<v<<endl;exit(0);}
    if(v<x and v>maxi)
      maxi=v,index=vo[i-1];
  }

  int node=index;
  while(node!=-1){
    cout<<"? "<<node<<endl;
    int v,nex;cin>>v>>nex;
    if(v==-1 and nex==-1)exit(0);
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    node=nex;
  }
  cout<<"! -1"<<endl;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
          res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
struct nott{
  int i,next,value;
  nott(int i,int next,int value):i(i),next(next),value(value){}
  bool operator==(nott &arg){
    return i==arg.i;
  }
  bool operator<(nott &arg){
    return value<arg.value;
  }
};

vector<nott>h;
vector<int>vo;
int main()
{
  #if !ONLINE_JUDGE
  //freopen("in.txt","r",stdin);
  #endif
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);

  int n,start,x;cin>>n>>start>>x;
  rep(i,n)vo.pb(i);
  random_shuffle(all(vo));
  int v,nex;
  for(int i=1;i<=min(n,1000);i++){
    cout<<"? "<<vo[i-1]<<endl;
    int v,nex;cin>>v>>nex;
    h.pb(nott(vo[i-1],nex,v));
  }
  sort(all(h));
  int maxi=-INF,mini=INF,miniindex=-1,maxiindex=-1;
  for(int i=0;i<min(n,1000);i++){
    if(h[i].value<x and h[i].value>maxi)
      maxi=h[i].value,maxiindex=h[i].i;
    else if(h[i].value>x and h[i].value<mini)
      mini=h[i].value,miniindex=h[i].i;
    else if(h[i].value==x)cout<<"! "<<x<<endl;
  }
  swap(miniindex,maxiindex);
  if(mini==INF){cout<<"! -1"<<endl;exit(0);}
  if(maxi=-INF)miniindex=start;

  int val;
  while(1){
    cout<<"? "<<miniindex<<endl;
    cin>>v>>nex;
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    if(miniindex==maxiindex)break;
    miniindex=nex;
  }
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
          res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
struct nott{
  int i,next,value;
  nott(int i,int next,int value):i(i),next(next),value(value){}
  bool operator==(nott &arg){
    return i==arg.i;
  }
  bool operator<(nott &arg){
    return value<arg.value;
  }
};

vector<nott>h;
vector<int>vo;
int main()
{
  #if !ONLINE_JUDGE
  //freopen("in.txt","r",stdin);
  #endif
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);

  int n,start,x;cin>>n>>start>>x;
  rep(i,n)vo.pb(i+1);
  random_shuffle(all(vo));

  for(int i=1;i<=min(n,1500);i++){
    cout<<"? "<<vo[i-1]<<endl;
    int v,nex;cin>>v>>nex;
    h.pb(nott(vo[i-1],nex,v));
  }
  sort(all(h));
  int maxi=-INF,mini=INF,miniindex=-1,maxiindex=-1;
  for(int i=0;i<min(n,1500);i++){
    if(h[i].value<x and h[i].value>maxi)
      maxi=h[i].value,maxiindex=h[i].i;
    else if(h[i].value>x and h[i].value<mini)
      mini=h[i].value,miniindex=h[i].i;
    else if(h[i].value==x)cout<<"! "<<x<<endl;
  }
  swap(miniindex,maxiindex);
  if(mini==INF){cout<<"! -1"<<endl;exit(0);}
  if(maxi=-INF)miniindex=start;

  int val;
  while(1){
    cout<<"? "<<miniindex<<endl;
    int v,nex;cin>>v>>nex;
    if(v>=x){cout<<"! "<<v<<endl;exit(0);}
    if(miniindex==maxiindex)break;
    miniindex=nex;
  }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

/*
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fs first
#define sc second
#define getfiles ifstream cin("input.txt"); ofstream cout("output.txt");
#define pii pair<int, int>

const int INF = 2000000005;
const ll BIG_INF = 2000000000000000005;
const int mod = 1000000007;
const int P = 31;
const ld PI = 3.141592653589793238462643;
const double eps = 1e-9;

using namespace std;
using namespace __gnu_pbds;

bool valid(int x, int y, int n, int m) {
    return x >= 0 && y >= 0 && x < n && y < m;
}

mt19937 rng(1999999973);

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = 50000 + 5;

int nxt[N], a[N], ans = INF, lt, n, x;

inline void ask(int i) {
    cout << "? " << i << endl;
    cin >> a[i] >> nxt[i];
}

signed main() {

    cin >> n >> lt >> x;
    ask(lt);

    for (int i = 1; i <= 1000; i++) {
        int i = rng() % n + 1;
        ask(i);
        if (a[i] <= x && a[i] > a[lt])
            lt = i;
    }
    while(nxt[lt] != -1 && a[lt] < x) {
        ask(nxt[lt]);
        lt = nxt[lt];
    }
    if (a[lt] >= x) {
        cout << "! " << a[lt] << endl;
    }
    else {
        cout << "! " << -1 << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

/*
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fs first
#define sc second
#define getfiles ifstream cin("input.txt"); ofstream cout("output.txt");
#define pii pair<int, int>

const int INF = 2000000005;
const ll BIG_INF = 2000000000000000005;
const int mod = 1000000007;
const int P = 31;
const ld PI = 3.141592653589793238462643;
const double eps = 1e-9;

using namespace std;
using namespace __gnu_pbds;

bool valid(int x, int y, int n, int m) {
    return x >= 0 && y >= 0 && x < n && y < m;
}

mt19937 rng(1999999973);

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = 50000 + 5;

int nxt[N], a[N], ans = INF, lt, n, x;

inline void ask(int i) {
    cout << "? " << i << endl;
    cin >> a[i] >> nxt[i];
}

signed main() {

    cin >> n >> lt >> x;
    ask(lt);

    for (int i = 1; i <= 1000; i++) {
        int ind = rng() % n + 1;
        ask(ind);
        if (a[ind] <= x && a[ind] > a[lt])
            lt = ind;
    }
    while(nxt[lt] != -1 && a[lt] < x) {
        ask(nxt[lt]);
        lt = nxt[lt];
    }
    if (a[lt] >= x) {
        cout << "! " << a[lt] << endl;
    }
    else {
        cout << "! " << -1 << endl;
    }

    return 0;
}