#include <stdio.h>
#include <string.h>
int main(){
    int n,s,a,b,c,d,ans,max;
    while(scanf("%d %d",&n,&s)!=EOF){
        max=-9999;
        d=-2;
        for(c=0;c<n;c++){
            scanf("%d %d",&a,&b);
            if(a<s){
                ans=100-b;
                if(b==0){
                    ans=0;
                }
                if(ans>max){
                    max=ans;
                }
            }
            else if(a==s && b==0 ){
                ans=0;
                if(ans>max){
                    max=ans;
                }
            }
        }
        if(max>=0){
        printf("%d\n",max);
        }
        else{
            printf("%d\n",-1);
        }
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
int main(){
    int n,s,a,b,c,d,ans,max;
    while(scanf("%d %d",&n,&s)!=EOF){
        max=-9999;
        d=-2;
        for(c=0;c<n;c++){
            scanf("%d %d",&a,&b);
            if(a<s){
                d=2;
                if(100-b>max && b!=0){
                    max=100-b;
                }
            }
        }
        if(d==2){
            max=0;
        }
        if(max>=0){
        printf("%d\n",max);
        }
        else{
            printf("%d\n",-1);
        }
    }
    return 0;
}


#include <stdio.h>

int main()
{
	int n, i, s, min = 100, zero = 0;

	scanf ("%d %d", &n, &s);

	for (i = 0; i < n; i++) {
		int x, y;
		scanf ("%d %d", &x, &y);

		if (x + (y > 0) > s)
			continue;

		if (y < min)
			if (y == 0)
				zero = 1;
			else
				min = y;
	}

	printf ("%d", min < 100 ? 100 - min : zero == 1 ? 0 : -1);

	return 0;
}


#include <stdio.h>

int main()
{
	int n, i, s, min = 100;

	scanf ("%d %d", &n, &s);

	for (i = 0; i < n; i++) {
		int x, y;
		scanf ("%d %d", &x, &y);

		if (x + (y > 0) > s)
			continue;

		if (y > 0 && y < min)
			min = y;
	}

	printf ("%d", min == 100 ? -1 : 100 - min);

	return 0;
}


#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<ctype.h>

#define MAX( a, b ) ( ( a > b) ? a : b )
#define MIN( a, b ) ( ( a < b) ? a : b )
#define FOR(ii,aa,bb) for(ii=aa;ii<bb;ii++)
#define and &&
#define or ||
int a[100000],f=0;
void sort(int bas,int ort,int son){
  int s=0,m,b,temp[1000000],i;
  b=bas;
  m=ort+1;
  f=1;
  while((b<=ort) && (m<=son))
    if(a[b]<a[m])
    temp[s++] = a[b++];
    else
    temp[s++] = a[m++];
  while((b<=ort))
   temp[s++] = a[b++];
  while((m<=son))
    temp[s++] = a[m++];
  for(i=0; i<s; i++)
    a[bas+i] = temp[i];
}

void merg(int bas,int son){
  if(son<=bas)
  return;
  int ort=(bas+son)/2;
  merg(bas,ort);
  merg(ort+1,son);
  sort(bas,ort,son);}
int main () {

long long int x=0,n=0,s=0,i,j,y,cvp=0;
scanf("%lld %lld",&n,&s);
s*=100;
FOR(i,0,n){
	  scanf("%lld %lld",&x,&y);
		a[i]=(x*100)+y;}
merg(0,n-1);
FOR(i,0,n){
	cvp+=a[i];
	if(cvp>s){
		if(!i){
			printf("-1");
			return 0;}
	cvp-=a[i];
	s-=cvp;
	printf("%lld",s-10);
	return 0;}}

return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
using namespace std;
const int MAXN=50005;
int N,X,Start,MaxV=-1,Seed;
int main()
{
	srand(time(0));
	cin>>N>>Start>>X;
	for(int I=1,Pos,Val,Next;I<=999;++I){
		Pos=rand()%N+1;
		printf("? %d\n",Pos);
		fflush(stdout);
		scanf("%d %d",&Val,&Next);
		if(Val>MaxV&&Val<X){
			MaxV=Val;
			Start=Next;
		}
		srand(Seed+=Next+Val);
	}
	for(int I=1,Val,Next;I<=1000;++I){
		if(Start==-1)break;
		printf("? %d\n",Start);
		fflush(stdout);
		scanf("%d %d",&Val,&Next);
		if(Val>=X){
			printf("! %d\n",Val);
			return 0;
		}
		Start=Next;
	}
	puts("! -1");
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
using namespace std;
const int MAXN=50005;
int N,X,Start,MaxV;
int main()
{
	srand(time(0));
	cin>>N>>Start>>X;
	for(int I=1,Pos,Val,Next;I<=999;++I){
		Pos=rand()%N+1;
		printf("? %d\n",Pos);
		fflush(stdout);
		scanf("%d %d",&Val,&Next);
		if(Val>MaxV&&Val<X){
			MaxV=Val;
			Start=Next;
		}
	}
	for(int I=1,Val,Next;I<=1000;++I){
		printf("? %d\n",Start);
		fflush(stdout);
		scanf("%d %d",&Val,&Next);
		if(Val>=X){
			printf("! %d\n",Val);
			return 0;
		}
		Start=Next;
		if(Start==-1){
			puts("! -1");
			return 0;
		}
	}
	puts("! -1");
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
using namespace std;
const int MAXN=50005;
int N,X,Start,MaxV=-1;
int main()
{
	srand(time(0));
	cin>>N>>Start>>X;
	for(int I=1,Pos,Val,Next;I<=999;++I){
		Pos=rand()%N+1;
		printf("? %d\n",Pos);
		fflush(stdout);
		scanf("%d %d",&Val,&Next);
		if(Val>MaxV&&Val<X){
			MaxV=Val;
			Start=Next;
		}
	}
	for(int I=1,Val,Next;I<=1000;++I){
		if(Start==-1){
			puts("! -1");
			return 0;
		}
		printf("? %d\n",Start);
		fflush(stdout);
		scanf("%d %d",&Val,&Next);
		if(Val>=X){
			printf("! %d\n",Val);
			return 0;
		}
		Start=Next;
	}
	puts("! -1");
	return 0;
}


# include <bits/stdc++.h>
using namespace std;

const int size1 = 4e5;
const int INF = 1e9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(1919);
    int n, start, x;
    cin >> n >> start >> x;
    static int num[size1], ch[size1], next[size1];
    num[1] = start;
    cout << "? " << start << endl;
    cin >> ch[1] >> next[1];
    int i;
    //static int num[size1], ch[size1], next[size1];
    for (i = 2; i <= 1000; i++)
    {
        num[i] = rand() % n + 1;
        cout << "? " << num[i] << endl;
        cin >> ch[i] >> next[i];
    }
    int maxx = -INF, imb = start;
    /*for (i = 1; i <= 1000; i++)
    {
        if (ch[i] < x && ch[i] > maxx)
        {
            maxx = ch[i];
            imb = num[i];
        }
    }
    */
    /*if (maxx == x)
    {
        cout << "! " << x;
        return 0;
    }
    */
    /*if (imb == -10)
    {
        cout << "! " << ch[1];
        return 0;
    }
    */
    //cout << "!!!!!" << endl;
    while (true)
    {
        if (imb == -1)
        {
            cout << "! " << -1;
            return 0;
        }
        cout << "? " << imb << endl;
        int pos, pos1;
        cin >> pos >> pos1;
        if (pos >= x)
        {
            cout << "! " << pos;
            return 0;
        }
        imb = pos1;
        //maxx = next[imb];
    }
    return 0;
}


# include <bits/stdc++.h>
using namespace std;

const int size1 = 4e5;
const int INF = 1e9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(1919);
    int n, start, x;
    cin >> n >> start >> x;
    static int num[size1], ch[size1], next[size1];
    num[1] = start;
    cout << "? " << start << endl;
    cin >> ch[1] >> next[1];
    int i;
    //static int num[size1], ch[size1], next[size1];
    for (i = 2; i <= 1000; i++)
    {
        num[i] = rand() % n + 1;
        cout << "? " << num[i] << endl;
        cin >> ch[i] >> next[i];
    }
    int maxx = -INF, imb = -10;
    for (i = 1; i <= 1000; i++)
    {
        if (ch[i] < x && ch[i] > maxx)
        {
            maxx = ch[i];
            imb = num[i];
        }
    }
    if (maxx == x)
    {
        cout << "! " << x;
        return 0;
    }
    if (imb == -10)
    {
        cout << "! " << ch[1];
        return 0;
    }
    //cout << "!!!!!" << endl;
    while (true)
    {
        if (imb == -1)
        {
            cout << "! " << -1;
            return 0;
        }
        cout << "? " << imb << endl;
        int pos, pos1;
        cin >> pos >> pos1;
        if (pos >= x)
        {
            cout << "! " << pos;
            return 0;
        }
        imb = pos1;
        //maxx = next[imb];
    }
    return 0;
}


# include <bits/stdc++.h>
using namespace std;

const int size1 = 4e5;
const int INF = 1e9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(1919);
    int n, start, x;
    cin >> n >> start >> x;
    static int num[size1], ch[size1], next[size1];
    num[1] = start;
    cout << "? " << start << endl;
    cin >> ch[1] >> next[1];
    int i;
    //static int num[size1], ch[size1], next[size1];
    for (i = 2; i <= 1000; i++)
    {
        num[i] = rand() % n + 1;
        cout << "? " << num[i] << endl;
        cin >> ch[i] >> next[i];
    }
    int maxx = -INF, imb = -10;
    for (i = 1; i <= 1000; i++)
    {
        if (ch[i] <= x && ch[i] > maxx)
        {
            maxx = ch[i];
            imb = num[i];
        }
    }
    if (maxx == x)
    {
        cout << "! " << x;
        return 0;
    }
    if (imb == -10)
    {
        cout << "! " << ch[1];
        return 0;
    }
    //cout << "!!!!!" << endl;
    while (true)
    {
        if (imb == -1)
        {
            cout << "! " << -1;
            return 0;
        }
        cout << "? " << imb << endl;
        int pos, pos1;
        cin >> pos >> pos1;
        if (pos >= x)
        {
            cout << "! " << pos;
            return 0;
        }
        imb = pos1;
        //maxx = next[imb];
    }
    return 0;
}


# include <bits/stdc++.h>
using namespace std;

const int size1 = 4e5;
const int INF = 1e9;

uniform_int_distribution uid(1,100000);

mt_19937 gen(uid);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(1919);
    int n, start, x;
    cin >> n >> start >> x;
    static int num[size1], ch[size1], next[size1];
    num[1] = start;
    cout << "? " << start << endl;
    cin >> ch[1] >> next[1];
    int i;
    //static int num[size1], ch[size1], next[size1];
    for (i = 2; i <= 1000; i++)
    {
        num[i] = (rand()) % n + 1;
        cout << "? " << num[i] << endl;
        cin >> ch[i] >> next[i];
    }
    int maxx = -INF, imb = start;
    for (i = 1; i <= 1000; i++)
    {
        if (ch[i] < x && ch[i] > maxx)
        {
            maxx = ch[i];
            imb = num[i];
        }
    }
    /*if (maxx == x)
    {
        cout << "! " << x;
        return 0;
    }
    */
    /*if (imb == -10)
    {
        cout << "! " << ch[1];
        return 0;
    }
    */
    //cout << "!!!!!" << endl;
    while (true)
    {
        if (imb == -1)
        {
            cout << "! " << -1;
            return 0;
        }
        cout << "? " << imb << endl;
        int pos, pos1;
        cin >> pos >> pos1;
        if (pos >= x)
        {
            cout << "! " << pos;
            return 0;
        }
        imb = pos1;
        //maxx = next[imb];
    }
    return 0;
}


# include <bits/stdc++.h>
using namespace std;

const int size1 = 4e5;
const int INF = 1e9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(1919);
    int n, start, x;
    cin >> n >> start >> x;
    static int num[size1], ch[size1], next[size1];
    num[1] = start;
    cout << "? " << start << endl;
    cin >> ch[1] >> next[1];
    int i;
    //static int num[size1], ch[size1], next[size1];
    for (i = 2; i <= 1000; i++)
    {
        num[i] = (rand() * rand()) % n + 1;
        cout << "? " << num[i] << endl;
        cin >> ch[i] >> next[i];
    }
    int maxx = -INF, imb = start;
    for (i = 1; i <= 1000; i++)
    {
        if (ch[i] < x && ch[i] > maxx)
        {
            maxx = ch[i];
            imb = num[i];
        }
    }
    /*if (maxx == x)
    {
        cout << "! " << x;
        return 0;
    }
    */
    /*if (imb == -10)
    {
        cout << "! " << ch[1];
        return 0;
    }
    */
    //cout << "!!!!!" << endl;
    while (true)
    {
        if (imb == -1)
        {
            cout << "! " << -1;
            return 0;
        }
        cout << "? " << imb << endl;
        int pos, pos1;
        cin >> pos >> pos1;
        if (pos >= x)
        {
            cout << "! " << pos;
            return 0;
        }
        imb = pos1;
        //maxx = next[imb];
    }
    return 0;
}


# include <bits/stdc++.h>
using namespace std;

const int size1 = 4e5;
const int INF = 1e9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(1919);
    int n, start, x;
    cin >> n >> start >> x;
    static int num[size1], ch[size1], next[size1];
    num[1] = start;
    cout << "? " << start << endl;
    cin >> ch[1] >> next[1];
    int i;
    //static int num[size1], ch[size1], next[size1];
    for (i = 2; i <= 1000; i++)
    {
        num[i] = rand() % n + 1;
        cout << "? " << num[i] << endl;
        cin >> ch[i] >> next[i];
    }
    int maxx = -INF, imb = start;
    for (i = 1; i <= 1000; i++)
    {
        if (ch[i] < x && ch[i] > maxx)
        {
            maxx = ch[i];
            imb = num[i];
        }
    }
    /*if (maxx == x)
    {
        cout << "! " << x;
        return 0;
    }
    */
    /*if (imb == -10)
    {
        cout << "! " << ch[1];
        return 0;
    }
    */
    //cout << "!!!!!" << endl;
    while (true)
    {
        if (imb == -1)
        {
            cout << "! " << -1;
            return 0;
        }
        cout << "? " << imb << endl;
        int pos, pos1;
        cin >> pos >> pos1;
        if (pos >= x)
        {
            cout << "! " << pos;
            return 0;
        }
        imb = pos1;
        //maxx = next[imb];
    }
    return 0;
}


#include <time.h>
#include<cstdlib>
#include <iostream>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1=-1,dd2=-1,a1,a2;
	cin>>n>>start>>x;
	cout<<"? "<<start<<endl;
	cin>>dd1>>dd2;
	if(dd1>x)
	{
		cout<<"! "<<dd1<<endl;
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		cout<<"? "<<d<<endl;
		cin>>a1>>a2;
		if(a1<=x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			cout<<"? "<<dd2;
			cin>>a1>>a2;
			if(a1>x)
			{
				cout<<"! "<<a1<<endl;
			}
			dd2=a2;
		}
	}
	cout<<"! "<<-1<<endl;
	return 0;
}


#include<time.h>
#include<cstdio>
#include<cstdlib>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
inline void finish(int a)
{
	printf("! %d\n",a);
	fflush(stdout);
	exit(0);
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1,dd2,a1,a2;
	//cin>>n>>start>>x;
	scanf("%d%d%d",&n,&start,&x);
	printf("? %d\n",start);
	//cout<<"? "<<start<<endl;
	fflush(stdout);
	//cin>>dd1>>dd2;
	scanf("%d%d",&dd1,&dd2);
	if(dd1>=x)
	{
		//cout<<"! "<<dd1<<endl;
		finish(dd1);
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		//cout<<"? "<<d<<endl;
		printf("? %d\n",d);
		fflush(stdout);
		//cin>>a1>>a2;
		scanf("%d%d",&a1,&a2);
		if(a1<x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			printf("? %d\n",dd2);
			//cout<<"? "<<dd2;
			fflush(stdout);
			//cin>>a1>>a2;
			scanf("%d%d",&a1,&a2);
			if(a1>=x)
			{
				//cout<<"! "<<a1<<endl;
				finish(a1);
				return 0;
			}
			dd2=a2;
		}
		else break;
	}
	finish(-1);
	return 0;
}


#include <time.h>
#include<cstdlib>
#include <iostream>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1,dd2,a1,a2;
	cin>>n>>start>>x;
	cout<<"? "<<start<<endl;
	cin>>dd1>>dd2;
	if(dd1>x)
	{
		cout<<"! "<<dd1<<endl;
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		cout<<"? "<<d<<endl;
		cin>>a1>>a2;
		if(a1<=x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			cout<<"? "<<dd2;
			cin>>a1>>a2;
			if(a1>x)
			{
				cout<<"! "<<a1<<endl;
				return 0;
			}
			dd2=a2;
		}
		else break;
	}
	cout<<"! "<<-1<<endl;
	return 0;
}


#include<time.h>
#include<cstdio>
#include<cstdlib>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
inline void finish(int a)
{
	printf("! %d\n",a);
	fflush(stdout);
	exit(0);
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1,dd2,a1,a2;
	//cin>>n>>start>>x;
	scanf("%d %d %d",&n,&start,&x);
	printf("? %d\n",start);
	//cout<<"? "<<start<<endl;
	fflush(stdout);
	//cin>>dd1>>dd2;
	scanf("%d %d",&dd1,&dd2);
	if(dd1>=x)
	{
		//cout<<"! "<<dd1<<endl;
		finish(dd1);
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		//cout<<"? "<<d<<endl;
		printf("? %d\n",d);
		fflush(stdout);
		//cin>>a1>>a2;
		scanf("%d %d",&a1,&a2);
		if(a1<x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			printf("? %d\n",dd2);
			//cout<<"? "<<dd2;
			fflush(stdout);
			//cin>>a1>>a2;
			scanf("%d %d",&a1,&a2);
			if(a1>=x)
			{
				//cout<<"! "<<a1<<endl;
				finish(a1);
				return 0;
			}
			dd2=a2;
		}
		else break;
	}
	finish(-1);
	return 0;
}


#include<time.h>
#include<cstdlib>
#include<iostream>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
inline void finish(int a)
{
	cout<<a<<endl;
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1,dd2,a1,a2;
	cin>>n>>start>>x;
	cout<<"? "<<start<<endl;
	cin>>dd1>>dd2;
	if(dd1>=x)
	{
		finish(dd1);
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		cout<<"? "<<d<<endl;
		cin>>a1>>a2;
		if(a1<x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			cout<<"? "<<dd2;
			cin>>a1>>a2;
			if(a1>=x)
			{
				finish(a1);
				return 0;
			}
			dd2=a2;
		}
		else break;
	}
	finish(-1);
	return 0;
}


#include<time.h>
#include<cstdlib>
#include<iostream>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
inline void finish(int a)
{
	cout<<a<<endl;
	exit(0);
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1,dd2,a1,a2;
	cin>>n>>start>>x;
	cout<<"? "<<start<<endl;
	cin>>dd1>>dd2;
	if(dd1>=x)
	{
		finish(dd1);
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		cout<<"? "<<d<<endl;
		cin>>a1>>a2;
		if(a1<x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			cout<<"? "<<dd2;
			cin>>a1>>a2;
			if(a1>=x)
			{
				finish(a1);
				return 0;
			}
			dd2=a2;
		}
		else break;
	}
	finish(-1);
	return 0;
}


#include <time.h>
#include<cstdlib>
#include <iostream>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1,dd2,a1,a2;
	cin>>n>>start>>x;
	cout<<"? "<<start<<endl;
	fflush(stdout);
	cin>>dd1>>dd2;
	if(dd1>x)
	{
		cout<<"! "<<dd1<<endl;
		fflush(stdout);
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		cout<<"? "<<d<<endl;
		fflush(stdout);
		cin>>a1>>a2;
		if(a1<=x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			cout<<"? "<<dd2;
			fflush(stdout);
			cin>>a1>>a2;
			if(a1>x)
			{
				cout<<"! "<<a1<<endl;
				fflush(stdout);
				return 0;
			}
			dd2=a2;
		}
		else break;
	}
	cout<<"! "<<-1<<endl;
	fflush(stdout);
	return 0;
}


#include<time.h>
#include<cstdlib>
#include<iostream>
#include<cstdio>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1,dd2,a1,a2;
	cin>>n>>start>>x;
	cout<<"? "<<start<<endl;
	fflush(stdout)
	cin>>dd1>>dd2;
	if(dd1>=x)
	{
		cout<<"! "<<dd1<<endl;
		fflush(stdout)
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		cout<<"? "<<d<<endl;
		fflush(stdout)
		cin>>a1>>a2;
		if(a1<x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			cout<<"? "<<dd2;
			fflush(stdout)
			cin>>a1>>a2;
			if(a1>=x)
			{
				cout<<"! "<<a1<<endl;
				fflush(stdout)
				return 0;
			}
			dd2=a2;
		}
		else break;
	}
	cout<<"! "<<-1<<endl;
	fflush(stdout)
	return 0;
}


#include <time.h>
#include<cstdlib>
#include <iostream>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1=-1,dd2=-1,a1,a2;
	cin>>n>>start>>x;
	cout<<"? "<<start<<endl;
	fflush(stdout);
	cin>>dd1>>dd2;
	if(dd1>x)
	{
		cout<<"! "<<dd1<<endl;
		fflush(stdout);
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		cout<<"? "<<d<<endl;
		fflush(stdout);
		cin>>a1>>a2;
		if(a1<=x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			cout<<"? "<<dd2;
			fflush(stdout);
			cin>>a1>>a2;
			if(a1>x)
			{
				cout<<"! "<<a1<<endl;
				fflush(stdout);
				return 0;
			}
			dd2=a2;
		}
	}
	cout<<"! "<<-1<<endl;
	fflush(stdout);
	return 0;
}


#include <time.h>
#include<cstdlib>
#include <iostream>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1,dd2,a1,a2;
	cin>>n>>start>>x;
	cout<<"? "<<start<<endl;
	cin>>dd1>>dd2;
	if(dd1>x)
	{
		cout<<"! "<<dd1<<endl;
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		cout<<"? "<<d<<endl;
		cin>>a1>>a2;
		if(a1<=x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			cout<<"? "<<dd2;
			fflush(stdout);
			cin>>a1>>a2;
			if(a1>x)
			{
				cout<<"! "<<a1<<endl;
				return 0;
			}
			dd2=a2;
		}
		else break;
	}
	cout<<"! "<<-1<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
inline void finish(int a)
{
	cout<<"! "<<a<<endl;
	exit(0);
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1,dd2,a1,a2;
	//cin>>n>>start>>x;
	scanf("%d%d%d",&n,&start,&x);
	cout<<"? "<<start<<endl;
	//cin>>dd1>>dd2;
	scanf("%d%d",&dd1,&dd2);
	if(dd1>=x)
	{
		finish(dd1);
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		cout<<"? "<<d<<endl;
		//cin>>a1>>a2;
		scanf("%d%d",&a1,&a2);
		if(a1<x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			cout<<"? "<<dd2;
			//cin>>a1>>a2;
			scanf("%d%d",&a1,&a2);
			if(a1>=x)
			{
				finish(a1);
				return 0;
			}
			dd2=a2;
		}
		else break;
	}
	finish(-1);
	return 0;
}


#include<time.h>
#include<cstdlib>
#include<iostream>
#include<cstdio>
using namespace std;
int RAND(int a)
{
	return abs((rand()<<15)+rand())%a;
}
int main()
{
	srand(unsigned((long long)new char));
	int n,start,x,dd1,dd2,a1,a2;
	cin>>n>>start>>x;
	cout<<"? "<<start<<endl;
	fflush(stdout);
	cin>>dd1>>dd2;
	if(dd1>=x)
	{
		cout<<"! "<<dd1<<endl;
		fflush(stdout);
		return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		int d=RAND(n)+1;
		cout<<"? "<<d<<endl;
		fflush(stdout);
		cin>>a1>>a2;
		if(a1<x&&a1>dd1)
		{
			dd1=a1;
			dd2=a2;
		}
	}
	for(int i=1;i<=999;i++)
	{
		if(dd2!=-1)
		{
			cout<<"? "<<dd2;
			fflush(stdout);
			cin>>a1>>a2;
			if(a1>=x)
			{
				cout<<"! "<<a1<<endl;
				fflush(stdout);
				return 0;
			}
			dd2=a2;
		}
		else break;
	}
	cout<<"! "<<-1<<endl;
	fflush(stdout);
	return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdlib>

using namespace std;

#define PB push_back
#define MP make_pair
#define L first
#define R second

typedef pair<int, int> pie;

const int maxn = 5e4 + 100;
const int ted = 1600;
int a[maxn];

int main() {
	ios_base::sync_with_stdio(false);
	srand ( unsigned ( std::time(0) ) );
	int n, st, x;
	cin >> n >> st >> x;
	for (int i = 1; i <= n; i++)
		a[i] = i;
	random_shuffle(a + 1, a + n + 1);
	int val, y;
	cout << '?' << " " << st << endl;
	cin >> val >> y;
	if (x <= val) {
		cout << '!' << " " << val << endl;
		return 0;
	}
	int best = val;
	int pos = st;
	int nx = y;
	for (int i = 1; i <= ted; i++) {
		cout << '?' << " " << a[i] << endl;
		cin >> val >> y;
		if (val == -1 and y == -1)
			return 0;
		if (x > val and val > best) {
			best = val;
			pos = a[i];
			nx = y;
		}
	}
	while (true) {
		if (nx == -1) {
			cout << '!' << " " << "-1" << endl;
			return 0;
		}
		cout << '?' << " " << nx << endl;
		cin >> val >> y;
		if (val >= x) {
			cout << '!' << " " << val << endl;
			return 0;
		}
		pos = nx;
		best = val;
		nx = y;
	}

}


#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdlib>

using namespace std;

#define PB push_back
#define MP make_pair
#define L first
#define R second

typedef pair<int, int> pie;

const int maxn = 5e4 + 100;
const int ted = 1600;
int a[maxn];

int main() {
	ios_base::sync_with_stdio(false);
	srand ( unsigned ( std::time(0) ) );
	int n, st, x;
	cin >> n >> st >> x;
	for (int i = 1; i <= n; i++)
		a[i] = i;
	random_shuffle(a + 1, a + n + 1);
	int val, y;
	cout << '?' << " " << st << endl;
	cin >> val >> y;
	if (x <= val) {
		cout << '!' << " " << val << endl;
		return 0;
	}
	int best = val;
	int pos = st;
	int nx = y;
	for (int i = 1; i <= ted and i <= n; i++) {
		cout << '?' << " " << a[i] << endl;
		cin >> val >> y;
		if (val == -1 and y == -1)
			return 0;
		if (x > val and val > best) {
			best = val;
			pos = a[i];
			nx = y;
		}
	}
	while (true) {
		if (nx == -1) {
			cout << '!' << " " << "-1" << endl;
			return 0;
		}
		cout << '?' << " " << nx << endl;
		cin >> val >> y;
		if (val >= x) {
			cout << '!' << " " << val << endl;
			return 0;
		}
		pos = nx;
		best = val;
		nx = y;
	}

}


#include <bits/stdc++.h>
using namespace std;

int N, Start, X, head, Next;

class rec{
	public:
	int x, v, n;
} q[510];

bool cmp(const rec &A, const rec &B){
	return A.v < B.v;
}

int main(){
	srand(time(0));
	scanf("%d%d%d", &N, &Start, &X);
	for (int i = 1; i <= 500; i++){
		int x = rand() % N + 1;
		if (i == 1)
			x = Start;
		int v, n;
		printf("? %d\n", x);
		fflush(stdout);
		scanf("%d%d", &v, &n);
		q[i].x = x;
		q[i].v = v;
		q[i].n = n;
	}
	sort(q + 1, q + 500 + 1, cmp);
	if (q[1].v >= X){
		printf("! %d\n", q[1].v);
		fflush(stdout);
		return 0;
	}
	head = q[500].x;
	Next = q[500].n;
	for (int i = 1; i < 500; i++)
		if (q[i + 1].v >= X){
			head = q[i].x;
			Next = q[i].n;
			break;
		}
	for (int i = 1; i <= 1499; i++){
		int v, n;
		if (Next == -1) break;
		printf("? %d\n", Next);
		fflush(stdout);
		scanf("%d%d", &v, &n);
		if (v >= X){
			printf("! %d\n", v);
			fflush(stdout);
			return 0;
		}
		if (n == -1){
			printf("! -1\n");
			fflush(stdout);
			return 0;
		}
		head = Next;
		Next = n;
	}
	printf("! -1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int N, Start, X, head, Next;
size_t seed;

const int maxn = 500;

class rec{
	public:
	int x, v, n;
} q[510];

bool cmp(const rec &A, const rec &B){
	return A.v < B.v;
}

size_t randomize(){
	return seed = 1103515245UL * seed + 12345UL;
}

int main(){
	srand(time(0));
	scanf("%d%d%d", &N, &Start, &X);
	seed = rand();
	for (int i = 1; i <= maxn; i++){
		int x = randomize() % N + 1;
		if (i == 1)
			x = Start;
		int v, n;
		printf("? %d\n", x);
		fflush(stdout);
		scanf("%d%d", &v, &n);
		q[i].x = x;
		q[i].v = v;
		q[i].n = n;
	}
	sort(q + 1, q + maxn + 1, cmp);
	if (q[1].v >= X){
		printf("! %d\n", q[1].v);
		fflush(stdout);
		return 0;
	}
	head = q[maxn].x;
	Next = q[maxn].n;
	for (int i = 1; i < maxn; i++)
		if (q[i + 1].v >= X){
			head = q[i].x;
			Next = q[i].n;
			break;
		}
	for (int i = 1; i <= 1300; i++){
		int v, n;
		if (Next == -1) break;
		printf("? %d\n", Next);
		fflush(stdout);
		scanf("%d%d", &v, &n);
		if (v >= X){
			printf("! %d\n", v);
			fflush(stdout);
			return 0;
		}
		if (n == -1){
			printf("! -1\n");
			fflush(stdout);
			return 0;
		}
		head = Next;
		Next = n;
	}
	printf("! -1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int N, Start, X, head, Next;

class rec{
	public:
	int x, v, n;
} q[50010];

bool cmp(const rec &A, const rec &B){
	return A.v < B.v;
}

int main(){
	srand(time(0));
	scanf("%d%d%d", &N, &Start, &X);
	for (int i = 1; i <= 500; i++){
		int x = rand() % N + 1;
		if (i == 1)
			x = Start;
		int v, n;
		printf("? %d\n", x);
		fflush(stdout);
		scanf("%d%d", &v, &n);
		q[i].x = x;
		q[i].v = v;
		q[i].n = n;
	}
	sort(q + 1, q + 500 + 1, cmp);
	head = q[500].x;
	Next = q[500].n;
	for (int i = 1; i <= 500; i++)
		if (q[i + 1].v > X){
			head = q[i].x;
			Next = q[i].n;
			break;
		}
	for (int i = 1; i <= 1499; i++){
		int v, n;
		printf("? %d\n", Next);
		fflush(stdout);
		scanf("%d%d", &v, &n);
		if (v > X){
			printf("! %d\n", v);
			fflush(stdout);
			return 0;
		}
		if (n == -1){
			printf("! -1\n");
			fflush(stdout);
			return 0;
		}
		head = Next;
		Next = n;
	}
	printf("! -1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int N, Start, X, head, Next;

class rec{
	public:
	int x, v, n;
} q[510];

bool cmp(const rec &A, const rec &B){
	return A.v < B.v;
}

int main(){
	srand(time(0));
	scanf("%d%d%d", &N, &Start, &X);
	for (int i = 1; i <= 500; i++){
		int x = rand() % N + 1;
		if (i == 1)
			x = Start;
		int v, n;
		printf("? %d\n", x);
		fflush(stdout);
		scanf("%d%d", &v, &n);
		q[i].x = x;
		q[i].v = v;
		q[i].n = n;
	}
	sort(q + 1, q + 500 + 1, cmp);
	if (q[1].v >= X){
		printf("! %d\n", q[1].v);
		return 0;
	}
	head = q[500].x;
	Next = q[500].n;
	for (int i = 1; i <= 500; i++)
		if (q[i + 1].v >= X){
			head = q[i].x;
			Next = q[i].n;
			break;
		}
	for (int i = 1; i <= 1499; i++){
		int v, n;
		if (Next == -1) break;
		printf("? %d\n", Next);
		fflush(stdout);
		scanf("%d%d", &v, &n);
		if (v >= X){
			printf("! %d\n", v);
			fflush(stdout);
			return 0;
		}
		if (n == -1){
			printf("! -1\n");
			fflush(stdout);
			return 0;
		}
		head = Next;
		Next = n;
	}
	printf("! -1\n");
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef pair<int,int> node;

int n,x,head;
node st;

node query(int x)
{
    printf("? %d\n",x);
    fflush(stdout);
    int a,b;
    scanf("%d%d",&a,&b);
    return make_pair(b,a);
}

int main(){
    srand(20020624);
    scanf("%d%d%d",&n,&st.first,&x);
    st.second=-1;
    for(int i=1;i<1000;i++){
        int t=(rand()*rand())%n+1;
        node now=query(t);
        if(now.second<x&&now.second>st.second)
            st=now;
    }
    for(int i=1,b=st.first;i<999;i++){
        if(b==-1)
            break;
        node now=query(b);
        if(now.second>=x)
        {
            printf("! %d\n",now.second);
            exit(0);
        }
        b=now.first;
    }
    printf("! -1\n");
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<auxx-x)auxx=v;
	for(int i=0;i<999+500;i++)
	{
		int a=rand()%n+1;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	for(int i=0;i<999-500;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<auxx-x)auxx=v;
	int aux=sqrt(n);
	for(int i=0;i<aux;i++)
	{
		int a=rand()%n+1;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	for(int i=0;i<2000-2-aux;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
bool vis[50010];
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v>=x)
	{
		printf("! %d\n",v);
		fflush(stdout);
		return 0;
	}
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<auxx-x)auxx=v;
	int aux=min(999,n);
	vis[0]=true;
	for(int i=0;i<aux;i++)
	{
		int a=0;
		int count=999;
		while(vis[a] && count)
		{
			a=rand()%n+1;
			count--;
		}
		if(vis[a])
		{
			aux=i;
			break;
		}
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	for(int i=0;i<2000-2-aux;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-1;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	if(v<x)
	{
		if(bestv==-1 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else
	{
	    printf("! %d\n",v);
    	fflush(stdout);
    	return 0;
	}
	for(int i=0;i<999;i++)
	{
		int a=abs((rand()<<15)|rand())%n+1;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-1 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
	}
	for(int i=0;i<999;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! -1\n");
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	if(v<=x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}

	for(int i=0;i<999;i++)
	{
		int a=rand()%n+1;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<=x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}

	}
	for(int i=0;i<999;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! -1\n");
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
bool vis[50010];
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v>=x)
	{
		printf("! %d\n",v);
		fflush(stdout);
		return 0;
	}
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<auxx-x)auxx=v;
	int aux=min(999,n);
	vis[0]=true;
	for(int i=0;i<aux;i++)
	{
		int a=0;
		int count=999;
		while(vis[a] && count)
		{
			a=rand()%n+1;
			count--;
		}
		if(vis[a])
		{
			aux=i;
			break;
		}
		vis[a]=true;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	if(auxx==-1)
	for(int i=0;i<1999-2-aux;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	else while(true)
	{
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<auxx-x)auxx=v;
	for(int i=0;i<999;i++)
	{
		int a=rand()%n+1;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	for(int i=0;i<999;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
bool vis[50010];
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v>=x)
	{
		printf("! %d\n",v);
		fflush(stdout);
		return 0;
	}
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<auxx-x)auxx=v;
	int aux=min(999,n);
	vis[0]=true;
	for(int i=0;i<aux;i++)
	{
		int a=0;
		int count=999;
		while(vis[a] && count)
		{
			a=rand()%n+1;
			count--;
		}
		if(vis[a])
		{
			aux=i;
			break;
		}
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	if(auxx==-1)
	for(int i=0;i<2000-2-aux;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	else while(true)
	{
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-1;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	if(v<x)
	{
		if(bestv==-1 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	for(int i=0;i<999;i++)
	{
		int a=abs((rand()<<16)^rand())%n+1;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-1 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
	}
	for(int i=0;i<999;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! -1\n");
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
bool vis[50010];
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<auxx-x)auxx=v;
	int aux=min(999,n);
	vis[0]=true;
	for(int i=0;i<aux;i++)
	{
		int a=0;
		int count=999;
		while(vis[a] && count)
		{
			a=rand()%n+1;
			count--;
		}
		if(vis[a])
		{
			aux=i;
			break;
		}
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	for(int i=0;i<2000-2-aux;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<v-auxx)auxx=v;
	for(int i=0;i<999;i++)
	{
		int a=rand()%n+1;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<v-auxx)auxx=v;
	}
	for(int i=0;i<999;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
bool vis[50010];
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v>=x)
	{
		printf("! %d\n",v);
		fflush(stdout);
		return 0;
	}
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<auxx-x)auxx=v;
	int aux=min(100,n);
	vis[0]=true;
	for(int i=0;i<aux;i++)
	{
		int a=0;
		int count=999;
		while(vis[a] && count)
		{
			a=rand()%n+1;
			count--;
		}
		if(vis[a])
		{
			aux=i;
			break;
		}
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	for(int i=0;i<2000-2-aux;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
bool vis[50010];
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v>=x)
	{
		printf("! %d\n",v);
		fflush(stdout);
		return 0;
	}
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<auxx-x)auxx=v;
	int aux=min(999,n);
	vis[0]=true;
	for(int i=0;i<aux;i++)
	{
		int a=i+1;
		int count=999;
		while(vis[a] && count)
		{
			a=rand()%n+1;
			count--;
		}
		if(vis[a])
		{
			aux=i;
			break;
		}
		vis[a]=true;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	if(auxx==-1)
	for(int i=0;i<1999-2-aux;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	else while(true)
	{
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-1;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	if(v<x)
	{
		if(bestv==-1 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else
	{
	    printf("! %d\n",v);
    	fflush(stdout);
    	return 0;
	}
	for(int i=0;i<999;i++)
	{
		int a=abs((rand()<<16)^rand())%n+1;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-1 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
	}
	for(int i=0;i<999;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! -1\n");
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scd(a) scanf("%lf",&a)
#define scd2(a,b) scanf("%lf%lf",&a,&b)
#define scd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define scd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define BUFF ios::sync_with_stdio(false)
#define endl "\n"
#define power(a,x) __gnu_cxx::power(a, x)
#define forN(i,n) for(int i=0;i<n;i++)
#define eps 1e-5
#define INF INT_MAX
#define INFLL LLONG_MAX
#define gcd(a,b) __gcd(a,b)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int> >vvi;
const int inf = 0x3f3f3f3f;
bool vis[50010];
int main()
{
	srand (time(NULL));
	int n,s,x;
	sc3(n,s,x);
	printf("? %d\n",s);
	fflush(stdout);
	int bestv=-5;
	int nxt=-1;
	int v,ind;
	sc2(v,ind);
	int auxx=-1;
	if(v>=x)
	{
		printf("! %d\n",v);
		fflush(stdout);
		return 0;
	}
	if(v<x)
	{
		if(bestv==-5 or (x-v)<x-bestv)
		{
			bestv=v;
			nxt=ind;
		}
	}
	else if(auxx==-1 or v-x<auxx-x)auxx=v;
	int roubadinha=min(n/2,300);
	int aux=min(999,n)-roubadinha;
	vis[0]=true;

	for(int i=n/2;i<n/2+roubadinha;i++)
	{
		int a=i;
		vis[a]=true;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	for(int i=0;i<aux;i++)
	{
		int a=rand()%n+1;
		int count=999;
		while(vis[a] && count)
		{
			a=rand()%n+1;
			count--;
		}
		if(vis[a])
		{
			aux=i;
			break;
		}
		vis[a]=true;
		printf("? %d\n",a);
		fflush(stdout);

		sc2(v,ind);
		if(v<x)
		{
			if(bestv==-5 or (x-v)<x-bestv)
			{
				bestv=v;
				nxt=ind;
			}
		}
		else if(auxx==-1 or v-x<auxx-x)auxx=v;
	}
	if(auxx==-1)
	for(int i=0;i<1999-2-aux-roubadinha;i++)
	{
		if(nxt==-1)break;
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	else while(true)
	{
		printf("? %d\n",nxt);
		fflush(stdout);
		sc2(v,ind);
		nxt=ind;
		if(v>=x)
		{
			printf("! %d\n",v);
			fflush(stdout);
			return 0;
		}
	}
	printf("! %d\n",auxx);
	fflush(stdout);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<time.h>
using namespace std;
int visit[50505];
int value[50505],next[50505];
int main()
{
	memset(value,-1,sizeof(value));
	int n,start,x;
	scanf("%d %d %d",&n,&start,&x);
	srand(time(0));
	printf("? %d\n",start);
	fflush(stdout);
	scanf("%d %d",&value[start],&next[start]);
	visit[start]=true;
	for(int i=1;i<=999;i++)
	{
		if(i+1>n)
			break;
		int x=rand()%n+1;
		while(visit[x])
			x=rand()%n+1;
		visit[x]=true;
		printf("? %d\n",x);
		scanf("%d %d",&value[x],&next[x]);
	}
	if(value[start]>x)
		return puts("! -1"),0;
	int mx=value[start];
	int id=start;
	for(int i=1;i<=n;i++)
		if(value[i]>mx&&value[i]<=x)
		{
			mx=value[i];
			id=i;
		}
	if(mx==x)
		return printf("! %d\n",x),0;
	int cur=next[id];
	int prev=mx;
	int t=1;
	while(cur!=-1&&t<=999)
	{
		printf("? %d\n",cur);
		fflush(stdout);
		scanf("%d %d",&value[cur],&next[cur]);
		if(value[cur]>=x)
			return printf("! %d\n",value[cur]),0;
		prev=value[cur];
		cur=next[cur];
		t++;
	}
	printf("! %d\n",prev);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<time.h>
using namespace std;
int visit[50505];
int value[50505],next[50505];
int main()
{
	memset(value,-1,sizeof(value));
	int n,start,x;
	scanf("%d %d %d",&n,&start,&x);
	srand(time(0));
	printf("? %d\n",start);
	fflush(stdout);
	scanf("%d %d",&value[start],&next[start]);
	visit[start]=true;
	for(int i=1;i<=999;i++)
	{
		if(i+1>n)
			break;
		int x=(((long long)rand()<<15)|rand())%n+1;
		while(visit[x])
			x=(((long long)rand()<<15)|rand())%n+1;
		visit[x]=true;
		printf("? %d\n",x);
		fflush(stdout);
		scanf("%d %d",&value[x],&next[x]);
	}
	if(value[start]>x)
		return puts("! -1"),0;
	int mx=value[start];
	int id=start;
	for(int i=1;i<=n;i++)
		if(value[i]>mx&&value[i]<=x)
		{
			mx=value[i];
			id=i;
		}
	if(mx==x)
		return printf("! %d\n",x),0;
	int cur=next[id];
	int t=1;
	while(cur!=-1&&t<=999)
	{
		printf("? %d\n",cur);
		fflush(stdout);
		scanf("%d %d",&value[cur],&next[cur]);
		if(value[cur]>=x)
			return printf("! %d\n",value[cur]),0;
		cur=next[cur];
		t++;
	}
	int mn=1000000001;
	for(int i=1;i<=n;i++)
		if(value[i]>=x&&value[i]<mn)
			mn=value[i];
	if(mn==1000000001)
		puts("! -1");
	else
		printf("! %d\n",mn);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<time.h>
using namespace std;
int visit[50505];
int value[50505],next[50505];
int main()
{
	memset(value,-1,sizeof(value));
	int n,start,x;
	scanf("%d %d %d",&n,&start,&x);
	srand(time(0));
	printf("? %d\n",start);
	fflush(stdout);
	scanf("%d %d",&value[start],&next[start]);
	visit[start]=true;
	for(int i=1;i<=999;i++)
	{
		if(i+1>n)
			break;
		int x=rand()%n+1;
		while(visit[x])
			x=rand()%n+1;
		visit[x]=true;
		printf("? %d\n",x);
		fflush(stdout);
		scanf("%d %d",&value[x],&next[x]);
	}
	if(value[start]>x)
		return puts("! -1"),0;
	int mx=value[start];
	int id=start;
	for(int i=1;i<=n;i++)
		if(value[i]>mx&&value[i]<=x)
		{
			mx=value[i];
			id=i;
		}
	if(mx==x)
		return printf("! %d\n",x),0;
	int cur=next[id];
	int prev=mx;
	int t=1;
	while(cur!=-1&&t<=999)
	{
		printf("? %d\n",cur);
		fflush(stdout);
		scanf("%d %d",&value[cur],&next[cur]);
		if(value[cur]>=x)
			return printf("! %d\n",value[cur]),0;
		prev=value[cur];
		cur=next[cur];
		t++;
	}
	int mn=1000000001;
	for(int i=1;i<=n;i++)
		if(value[i]>=x&&value[i]<mn)
			mn=value[i];
	if(mn==1000000001)
		puts("! -1");
	else
		printf("! %d\n",mn);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<time.h>
using namespace std;
int visit[50505];
int value[50505],next[50505];
int main()
{
	memset(value,-1,sizeof(value));
	int n,start,x;
	scanf("%d %d %d",&n,&start,&x);
	srand(time(0));
	printf("? %d\n",start);
	fflush(stdout);
	scanf("%d %d",&value[start],&next[start]);
	visit[start]=true;
	for(int i=1;i<=999;i++)
	{
		if(i+1>n)
			break;
		int x=(((long long)rand()<<15)|rand())%n+1;
		while(visit[x])
			x=(((long long)rand()<<15)|rand())%n+1;
		visit[x]=true;
		printf("? %d\n",x);
		fflush(stdout);
		scanf("%d %d",&value[x],&next[x]);
	}
	if(value[start]>x)
		return printf("! %d",value[start]),0;
	int mx=value[start];
	int id=start;
	for(int i=1;i<=n;i++)
		if(value[i]>mx&&value[i]<=x)
		{
			mx=value[i];
			id=i;
		}
	if(mx==x)
		return printf("! %d\n",x),0;
	int cur=next[id];
	int t=1;
	while(cur!=-1&&t<=999)
	{
		printf("? %d\n",cur);
		fflush(stdout);
		scanf("%d %d",&value[cur],&next[cur]);
		if(value[cur]>=x)
			return printf("! %d\n",value[cur]),0;
		cur=next[cur];
		t++;
	}
	int mn=1000000001;
	for(int i=1;i<=n;i++)
		if(value[i]>=x&&value[i]<mn)
			mn=value[i];
	if(mn==1000000001)
		puts("! -1");
	else
		printf("! %d\n",mn);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<time.h>
using namespace std;
int visit[50505];
int value[50505],next[50505];
int main()
{
	memset(value,-1,sizeof(value));
	int n,start,x;
	scanf("%d %d %d",&n,&start,&x);
	srand(time(0));
	printf("? %d\n",start);
	fflush(stdout);
	scanf("%d %d",&value[start],&next[start]);
	visit[start]=true;
	for(int i=1;i<=999;i++)
	{
		if(i+1>n)
			break;
		int x=rand()%n+1;
		while(visit[x])
			x=rand()%n+1;
		visit[x]=true;
		printf("? %d\n",x);
		fflush(stdout);
		scanf("%d %d",&value[x],&next[x]);
	}
	if(value[start]>x)
		return puts("! -1"),0;
	int mx=value[start];
	int id=start;
	for(int i=1;i<=n;i++)
		if(value[i]>mx&&value[i]<=x)
		{
			mx=value[i];
			id=i;
		}
	if(mx==x)
		return printf("! %d\n",x),0;
	int cur=next[id];
	int prev=mx;
	int t=1;
	while(cur!=-1&&t<=999)
	{
		printf("? %d\n",cur);
		fflush(stdout);
		scanf("%d %d",&value[cur],&next[cur]);
		if(value[cur]>=x)
			return printf("! %d\n",value[cur]),0;
		prev=value[cur];
		cur=next[cur];
		t++;
	}
	printf("! %d\n",prev);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<time.h>
using namespace std;
int visit[50505];
int value[50505],next[50505];
int main()
{
	memset(value,-1,sizeof(value));
	int n,start,x;
	scanf("%d %d %d",&n,&start,&x);
	srand(time(0));
	printf("? %d\n",start);
	fflush(stdout);
	scanf("%d %d",&value[start],&next[start]);
	visit[start]=true;
	for(int i=1;i<=999;i++)
	{
		if(i+1>n)
			break;
		int x=(((long long)rand()<<15)|rand())%n+1;
		while(visit[x])
			x=(((long long)rand()<<15)|rand())%n+1;
		visit[x]=true;
		printf("? %d\n",x);
		fflush(stdout);
		scanf("%d %d",&value[x],&next[x]);
	}
	if(value[start]>x)
		return puts("! %d",value[start]),0;
	int mx=value[start];
	int id=start;
	for(int i=1;i<=n;i++)
		if(value[i]>mx&&value[i]<=x)
		{
			mx=value[i];
			id=i;
		}
	if(mx==x)
		return printf("! %d\n",x),0;
	int cur=next[id];
	int t=1;
	while(cur!=-1&&t<=999)
	{
		printf("? %d\n",cur);
		fflush(stdout);
		scanf("%d %d",&value[cur],&next[cur]);
		if(value[cur]>=x)
			return printf("! %d\n",value[cur]),0;
		cur=next[cur];
		t++;
	}
	int mn=1000000001;
	for(int i=1;i<=n;i++)
		if(value[i]>=x&&value[i]<mn)
			mn=value[i];
	if(mn==1000000001)
		puts("! -1");
	else
		printf("! %d\n",mn);
	return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstring>
#include <cstdio>
#include <map>
#include <time.h>
#include <set>
#include <deque>
#include <algorithm>

using namespace std;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define sqr(x) (x) * (x)
#define forn(i, l, r) for(int i = l; i < r; i ++)
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define y1 salnk
#define N 200100
#define sz(a) (int)a.size()
#define ll long long
const int inf = (int)1e9;
const double pi = acos(-1.0);
const double eps = 1e-9;

int n, start, x;
vector <int> v;
set < pair <int, int> > q;
int qe;
int val, nxt;

int main () {
	scanf("%d%d%d", &n, &start, &x);
	for (int i = 1; i <= min(49100, n); i++) {
	 	if (i != start)
	 		v.pb(i);
	}
	srand(time(0));
	random_shuffle(v.begin(), v.end());
	q.insert(mp(-1, start));

	int res = inf;
	qe = 1999;

	for (int i = 0; i < min((int)v.size(), 999); i++) {
	     cout << "? " << v[i] << endl;
	     cin >> val >> nxt;
	     if(val >= x)
	     	res = min(val, x);
	     else
	 		q.insert(mp(val, nxt));
		qe--;;
	}

	set < pair <int, int> >  :: iterator  it = q.end();
	it--;
	int ind = (*it).second;

	for (int i = 0; i < qe; i++) {
	 	if (ind == -1) {
	 	     cout << "! -1" << endl;
	 	     return 0;
	 	}
	 	cout << "? " << ind << endl;
	 	cin >> val >> nxt;

	 	if (val >= x) {
	 	 	cout << "! " << val << endl;
	 	 	return 0;
	 	}
	 	ind = nxt;
	}

	if (res == inf)
		cout << "! -1" << endl;
	else
		cout << "! " << res << endl;

}


#include <iostream>
#include <fstream>
#include <time.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
int N, start, x;
int s, t, v, n, b, c;
int hash_num(ll num)
{
    return (int)((num*29+12237)%N);
}
int main()
{
    cin>>N>>start>>x;
    time_t timer;
    time(&timer);
    s = hash_num(timer);
    srand(s);
    cout<<"? "<<start<<endl;
    fflush(stdout);
    cin>>v>>n;
    b = v; c = start;
    if(b >= x)
    {
        cout<<"! "<<b<<endl;
        return 0;
    }
    for(int i=0; i<999; i++)
    {
        t = rand() % N + 1;
        t = hash_num(hash_num(hash_num(hash_num(t)+hash_num(i)+hash_num(i))+hash_num(i))+hash_num(i)) + 1;
        cout<<"? "<<t<<endl;
        fflush(stdout);
        cin>>v>>n;
        if(b<v && v < x)
        {
            b = v;
            c = t;
        }
    }
    for(int i=0; i<999; i++)
    {
        cout<<"? "<<c<<endl;
        fflush(stdout);
        cin>>v>>n;
        if(v >= x)
        {
            cout<<"! "<<v<<endl;
            return 0;
        }
        c = n;
        if(c==-1)
        {
            cout<<"! "<<-1<<endl;
        }
    }
}


#include<time.h>
#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
int n,start,x;
int ans=-1000;
int a,b;
int main()
{
    srand((unsigned)time(0));
    scanf("%d %d %d",&n,&start,&x);
    for(int i=0;i<1000;i++)
    {
        printf("? %d\n",((rand()%n)*(rand()%n))%n+1);
        fflush(stdout);
        scanf("%d %d",&a,&b);
        if(ans<a&&a<x)
        {
            ans=a;
            start=b;
        }
    }
    for(int i=1;i<1000;i++)
    {
        if(start==-1)
        {
            printf("! -1\n");
            return 0;
        }
        printf("? %d\n",start);
        fflush(stdout);
        scanf("%d %d",&a,&b);
        start=b;
        if(a>=x)
        {
            printf("! %d\n",a);
            return 0;
        }
    }
}


#include<cstdio>
#include<iostream>
#include<time.h>
using namespace std;
int n,start,x;
int ans=-1000;
int a,b;
int main()
{
    srand(time(0));
    scanf("%d %d %d",&n,&start,&x);
    for(int i=0;i<1000;i++)
    {
        printf("? %d\n",((rand()%n)*(rand()%n))%n+1);
        fflush(stdout);
        cin>>a>>b;
        if(ans<a&&a<x)
        {
            ans=a;
            start=b;
        }
    }
    for(int i=1;i<1000;i++)
    {
        if(start==-1)
        {
            printf("! -1\n");
            return 0;
        }
        printf("? %d\n",start);
        fflush(stdout);
        cin>>a>>b;
        if(a>=x)
        {
            printf("! %d\n",a);
            return 0;
        }
    }
}


#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
#define MAXN 50000
int N,X,W=-1,W_N,G,G_N;
bool Vis[MAXN+5];
int main() {
	srand(20041112);
	scanf("%d%d%d",&N,&W_N,&X);
	for(int i=1; i<=min(1000,N); i++) {
		int Add=abs(rand())%N;
		if(Add==0) Add=N;
		if(Vis[Add]){
			i--;
			continue;
		}
		Vis[Add]=true;
		printf("? %d\n",Add);
		fflush(stdout);
		scanf("%d %d",&G,&G_N);
		if(G==X) {
			printf("! %d\n",G);
			fflush(stdout);
			return 0;
		} else if(G_N==-1&&G<X) {
			printf("! %d\n",-1);
			fflush(stdout);
			return 0;
		} else if(G<X&&G>W) {
			W=G;
			W_N=G_N;
		}
	}
	for(int i=1; i<1000; i++) {
		printf("? %d\n",W_N);
		fflush(stdout);
		scanf("%d %d",&G,&G_N);
		if(G>=X) {
			printf("! %d\n",G);
			fflush(stdout);
			return 0;
		} else{
			W_N=G_N;
			if(G_N==-1) {
				printf("! %d\n",-1);
				fflush(stdout);
				return 0;
			}
		}
	}
	return 0;
}


#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
#define MAXN 50000
int N,X,W=-1,W_N,G,G_N;
int main() {
	srand(20041112);
	scanf("%d%d%d",&N,&W_N,&X);
	for(int i=1; i<=min(999,N); i++) {
		printf("? %d\n",abs((rand()<<15)+rand())%N+1);
		fflush(stdout);
		scanf("%d %d",&G,&G_N);
		if(G<=X&&G>W) {
			W=G;
			W_N=G_N;
		}
	}
	while(W<X&&W_N!=-1) {
		printf("? %d\n",W_N);
		fflush(stdout);
		scanf("%d %d",&W,&W_N);
	}
	if(W<X) printf("! -1\n");
	else printf("! %d\n",W);
	fflush(stdout);
	return 0;
}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-8

#define pb push_back

#define mod 1000000007

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, const U &b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, const U &b) {if(a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=(INT)a*a%m) if (b&1) ans=(INT)ans*a%m;

	return ans;

}

#define NN 55555

pii p[NN];

int f[NN];

void ask(int x) {

	printf("? %d\n", x);

	fflush(stdout);

	gn(p[x].x, p[x].y);

}

void answer(int x) {

	printf("! %d\n", x);

	exit(0);

}

int main() {

	int n, id, x;

	gn(n, id, x);

	for(int i=1; i<=n; i++) f[i]=i;

	srand(time(0));

	random_shuffle(f+1, f+n+1);

	ask(id);

	if(p[id].x>=x) answer(p[id].x);

	int N=min(n, 1000);

	for(int i=1; i<=N; i++) {

		ask(f[i]);

		int u=p[f[i]].x;

		if(u<x && u>p[id].x) id=f[i];

	}

	for(int i=0; i<1000; i++){

		ask(id);

		if(p[id].x>=x) answer(p[id].x);

		if(p[id].y==-1) answer(-1);

		id=p[id].y;

	}

}


#define ONLINE_JUDGE
#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)

    #define lld "%I64d"

#else

    #define lld "%lld"

#endif

#define NN 1111

map<int, int> flag;

pii info[NN];

int main() {

#ifndef ONLINE_JUDGE

//	freopen("in.in", "r", stdin);

//	freopen("out.out", "w", stdout);

	int _time=clock();

#endif

	int n, s, xx;

	cin>>n>>s>>xx;

	int nn=0;

	int ed=min(1000, (n+1)/2);

	for(int i=0; i<ed; i++) {

		int u=rand()%n+1;

		if(i==0) u=s;

		while(flag.count(u)) {

			u=rand()%n+1;

		}

		printf("? %d\n", u);

		fflush(stdout);

		int v, nxt;

		scanf("%d %d", &v, &nxt);

		if(i==0 && v>=xx) return printf("! %d\n", v), 0;

		if(nxt==-1 && v<xx) return puts("! -1");

		flag[u]=flag[nxt]=1;

		info[i].x=v;

		info[i].y=nxt;

	}

	sort(info, info+ed);

	int pos;

	for(int i=0; i<ed; i++) {

		if(info[i].x>xx) break;

		pos=i;

	}

	int q=info[pos].y;

	for(int i=0; i<1999-ed; i++) {

		printf("? %d\n", q);

		fflush(stdout);

		int v, nxt;

		scanf("%d %d", &v, &nxt);

		if(v>=xx) return printf("! %d\n", v), 0;

		if(nxt==-1) return puts("! -1");

		q=nxt;

	}

	if(n>4000) assert(0);

	else {

		while(1) ;

	}

	return puts("! -1");

#ifndef ONLINE_JUDGE

	cerr<<(int)(clock()-_time)<<endl;

#endif

	return 0;

}


#include<bits/stdc++.h>

#define x first

#define y second

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(x) ((x)*(x))

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctzl(x) (__builtin_ctzl(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, const U &b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, const U &b) {if(a<b) a=b;}

template <class T> inline void gn(T &x) {char c, sg=0; while(c=getchar(), (c>'9' || c<'0') && c!='-'); for((c=='-' ? sg=1, c=getchar() : 0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0'; if(sg) x=-x;}

template <class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}

template <class T1, class T2, class T3> inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1, x2), gn(x3);}

template <class T1, class T2, class T3, class T4> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1, x2, x3), gn(x4);}

template <class T1, class T2, class T3, class T4, class T5> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5) {gn(x1, x2, x3, x4), gn(x5);}

template <class T> inline void print(T x) {if(x<0) {putchar('-'); return print(-x);} if(x<10) {putchar('0'+x); return ;} print(x/10); putchar(x%10+'0');}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

template <class T1, class T2, class T3, class T4, class T5> inline void print(T1 x1, T2 x2, T3 x3, T4 x4, T5 x5) {printsp(x1), printsp(x2), printsp(x3), printsp(x4), println(x5);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 1000100

int a[NN];

pii pa[NN];

int main(){

#ifndef ONLINE_JUDGE

//	freopen("in.in", "r", stdin);

//	freopen("out.out", "w", stdout);

#endif

	srand(time(NULL));

	int n,src,x;

	gn(n,src,x);

	int nn=0;

	for(int i=1;i<=1000;i++){

		int xx=rand()%n+1;

		printf("%c %d\n",'?',xx);

		fflush(stdout);

		int y;

		gn(pa[++nn].x,y);

		pa[nn].y=xx;

	}

	sort(pa+1,pa+nn+1);

	for(int i=1;i<=nn;i++) a[i]=pa[i].x;

	if(a[1]<=x){

		int pos=upper_bound(a+1,a+nn+1,x)-a;

		pos--;

		src=pa[pos].y;

	}

	int D=999;

	while(D--){

		printf("%c %d\n",'?',src);

		fflush(stdout);

		int val,pos;

		gn(val,pos);

		if(val>=x){

			printf("%c %d\n",'!',val);

			fflush(stdout);

			return 0;

		}

		if(pos==-1) break;

		src=pos;

	}

	puts("-1");

}


#define ONLINE_JUDGE
#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)

    #define lld "%I64d"

#else

    #define lld "%lld"

#endif

#define NN 1111

map<int, int> flag;

pii info[NN];

int main() {

#ifndef ONLINE_JUDGE

//	freopen("in.in", "r", stdin);

//	freopen("out.out", "w", stdout);

	int _time=clock();

#endif

	int n, s, xx;

	cin>>n>>s>>xx;

	int nn=0;

	int ed=(n+1)/2;

	for(int i=0; i<ed; i++) {

		int u=rand()%n+1;

		if(i==0) u=s;

		while(flag.count(u)) {

			u=rand()%n+1;

		}

		printf("? %d\n", u);

		fflush(stdout);

		int v, nxt;

		scanf("%d %d", &v, &nxt);

		if(i==0 && v>=xx) return printf("! %d\n", v), 0;

		if(nxt==-1 && v<xx) return puts("! -1");

		flag[u]=flag[nxt]=1;

		info[i].x=v;

		info[i].y=nxt;

	}

	sort(info, info+ed);

	int pos;

	for(int i=0; i<ed; i++) {

		if(info[i].x>xx) break;

		pos=i;

	}

	int q=info[pos].y;

	for(int i=0; i<1999-ed; i++) {

		printf("? %d\n", q);

		fflush(stdout);

		int v, nxt;

		scanf("%d %d", &v, &nxt);

		if(v>=xx) return printf("! %d\n", v), 0;

		if(nxt==-1) return puts("! -1");

		q=nxt;

	}

	assert(0);

	return puts("! -1");

#ifndef ONLINE_JUDGE

	cerr<<(int)(clock()-_time)<<endl;

#endif

	return 0;

}


#define ONLINE_JUDGE
#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)

    #define lld "%I64d"

#else

    #define lld "%lld"

#endif

#define NN 2222

map<int, int> flag;

pii info[NN];

int id[NN];

int main() {

#ifndef ONLINE_JUDGE

//	freopen("in.in", "r", stdin);

//	freopen("out.out", "w", stdout);

	int _time=clock();

#endif

	int n, s, xx;

	cin>>n>>s>>xx;

	int nn=0;

	srand(time(NULL));

	int ed=min(1200, (n+1)/2);

	for(int i=0; i<ed; i++) id[i]=i+1;

	random_shuffle(id, id+ed);

	for(int i=0; i<ed; i++) {

		int u=id[i];

		if(i==0) u=s;

		printf("? %d\n", u);

		fflush(stdout);

		int v, nxt;

		scanf("%d %d", &v, &nxt);

		if(i==0 && v>=xx) {

			printf("! %d\n", v);

			fflush(stdout);

			return 0;

		}

		if(nxt==-1 && v<xx) {

			puts("! -1");

			fflush(stdout);

			return 0;

		}

		info[i].x=v;

		info[i].y=nxt;

	}

	sort(info, info+ed);

	int pos;

	for(int i=0; i<ed; i++) {

		if(info[i].x>=xx) break;

		pos=i;

	}

	int q=info[pos].y;

	for(int i=0; i<1999-ed; i++) {

		printf("? %d\n", q);

		fflush(stdout);

		int v, nxt;

		scanf("%d %d", &v, &nxt);

		if(v>=xx) {

			printf("! %d\n", v), 0;

			fflush(stdout);

			return 0;

		}

		if(nxt==-1) {

			puts("! -1");

			fflush(stdout);

			return 0;

		}

		q=nxt;

	}

	assert(0);

	puts("! -1");

	fflush(stdout);

#ifndef ONLINE_JUDGE

	cerr<<(int)(clock()-_time)<<endl;

#endif

	return 0;

}


#define ONLINE_JUDGE
#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)

    #define lld "%I64d"

#else

    #define lld "%lld"

#endif

#define NN 1111

map<int, int> flag;

pii info[NN];

int main() {

#ifndef ONLINE_JUDGE

//	freopen("in.in", "r", stdin);

//	freopen("out.out", "w", stdout);

	int _time=clock();

#endif

	int n, s, xx;

	cin>>n>>s>>xx;

	int nn=0;

	srand(time(NULL));

	int ed=min(500, (n+1)/2);

	int mx=0;

	for(int i=0; i<ed; i++) {

		int u=rand()%n+1;

		if(i==0) u=s;

		while(flag.count(u)) {

			u=rand()%n+1;

		}

		printf("? %d\n", u);

		fflush(stdout);

		int v, nxt;

		scanf("%d %d", &v, &nxt);

		smax(mx, v);

		if(i==0 && v>=xx) {

			printf("! %d\n", v);

			return 0;

		}

		if(nxt==-1 && v<xx) return puts("! -1");

		flag[u]=flag[nxt]=1;

		info[i].x=v;

		info[i].y=nxt;

	}

	if(mx<xx) {

		for(int i=ed; i<min(ed+500, n); i++) {

			int u=rand()%n+1;

			while(flag.count(u)) {

				u=rand()%n+1;

			}

			printf("? %d\n", u);

			fflush(stdout);

			int v, nxt;

			scanf("%d %d", &v, &nxt);

			smax(mx, v);

			if(nxt==-1 && v<xx) return puts("! -1");

			flag[u]=flag[nxt]=1;

			info[i].x=v;

			info[i].y=nxt;

		}

		ed=min(ed+500, n);

	}

	sort(info, info+ed);

	int pos;

	for(int i=0; i<ed; i++) {

		if(info[i].x>=xx) break;

		pos=i;

	}

	int q=info[pos].y;

	for(int i=0; i<1999-ed; i++) {

		printf("? %d\n", q);

		fflush(stdout);

		int v, nxt;

		scanf("%d %d", &v, &nxt);

		if(v>=xx) {

			printf("! %d\n", v);

			return 0;

		}

		if(nxt==-1) return puts("! -1");

		q=nxt;

	}

	if(n>30000) assert(0);

	else {

		while(1) ;

	}

	return puts("! -1");

#ifndef ONLINE_JUDGE

	cerr<<(int)(clock()-_time)<<endl;

#endif

	return 0;

}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-8

#define pb push_back

#define mod 1000000007

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, const U &b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, const U &b) {if(a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=(INT)a*a%m) if (b&1) ans=(INT)ans*a%m;

	return ans;

}

#define NN 50010

pii p[NN];

int f[NN];

void go(int x) {

	printf("? %d\n", x);

	fflush(stdout);

	gn(p[x].x, p[x].y);

}

void end(int x) {

	printf("! %d\n", x);

	exit(0);

}

int main() {

	int n, id, x;

	gn(n, id, x);

	for(int i=1; i<=n; i++) f[i]=i;

	random_shuffle(f+1, f+n+1);

	go(id);

	if(p[id].x>=x) end(p[id].x);

	int N=min(n, 310);

	for(int i=1; i<=N; i++) {

		go(f[i]);

		int u=p[f[i]].x;

		if(u<x && u>p[id].x) id=f[i];

	}

	while(p[id].x<x && ~p[id].y) {

		id=p[id].y;

		if(!p[id].y) go(id);

	}

	if(p[id].x>=x) end(p[id].x);

	else end(-1);

}


#define ONLINE_JUDGE
#include <bits/stdc++.h>

using namespace std;

#define NN 55555

bool vst[NN];

int main(){

	int N, X, st, p, val;

	cin>>N>>st>>X;

	printf("? %d\n", st);

	fflush(stdout);

	scanf("%d%d", &val, &p);

	if (X<val) {

		puts("! -1");

		return 0;

	}

	if (N<1999) {

		st=p;

		for (int i=0; i<N; i++){

			printf("? %d\n", st);

			fflush(stdout);

			scanf("%d %d", &val, &p);

			if (val>=X) {

				printf("! %d\n", val);

				return 0;

			}

			if (p<0) {

				puts("! -1");

				return 0;

			}

			st=p;

		}

	}

	vst[st]=1;

	int mm=val, pos=st;

	for (int i=0; i<1000; i++) {

		int n=rand()%N+1, nn=0;

		while (nn<N && vst[n]) n=rand()%N+1, nn++;

		if (vst[n]) continue;

		vst[n]=1;

		printf("? %d\n", n);fflush(stdout);

		scanf("%d%d", &val, &p);

		vst[p]=1;

		if (val>X) continue;

		if (val==X) {

			printf("! %d\n", X);

			return 0;

		}

		if (X-val<X-mm) {

			mm=val;

			pos=n;

		}

	}

	st=pos;

	for (int i=0; i<990; i++) {

		printf("? %d\n", st);fflush(stdout);

		scanf("%d%d", &val, &p);

		if (val>=X) {

			printf("! %d\n", val);

			return 0;

		}

		if (p<0) {

			puts("! -1");

			return 0;

		}

		st=p;

	}

	puts("! -1");

	return 0;

}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-8

#define pb push_back

#define mod 1000000007

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, const U &b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, const U &b) {if(a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=(INT)a*a%m) if (b&1) ans=(INT)ans*a%m;

	return ans;

}

#define NN 50010

pii p[NN];

int f[NN];

void go(int x) {

	printf("? %d\n", x);

	fflush(stdout);

	gn(p[x].x, p[x].y);

}

void end(int x) {

	printf("! %d\n", x);

	exit(0);

}

int main() {

	int n, id, x;

	gn(n, id, x);

	for(int i=1; i<=n; i++) f[i]=i;

	random_shuffle(f+1, f+n+1);

	go(id);

	if(p[id].x>=x) end(p[id].x);

	int N=min(n, 1000);

	for(int i=1; i<=N; i++) {

		go(f[i]);

		int u=p[f[i]].x;

		if(u<x && u>p[id].x) id=f[i];

	}

	while(p[id].x<x && ~p[id].y) {

		id=p[id].y;

		if(!p[id].y) go(id);

	}

	if(p[id].x>=x) end(p[id].x);

	else end(-1);

}


#include<bits/stdc++.h>

#define x first

#define y second

#define pb push_back

#define inf 0x3f3f3f3f3f

#define mod 10000000007

#define sq(x) ((x)*(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if (a<b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a>b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T>inline void printsp(T x) {print(x); putchar(' ');}

template<class T>inline void println(T x) {print(x); putchar('\n');}

template<class T, class U>inline void print(T x, U y) {printsp(x); println(y);}

template<class T, class U, class V>inline void print(T x, U y, V z) {printsp(x); printsp(y); println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a*a%m) if (!b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 55555

int id[NN];

pii p[NN];

void ask(int u){

	printf("? %d\n", u);

	fflush(stdout);

	gn(p[u].x, p[u].y);

}

void answer(int u){

printf("! %d\n", u);	exit(0);

}

int main() {

	int n, st, x;

	gn(n, st, x);

	srand(time(0));

	for(int i=1; i<=n; i++)	id[i]=i;

	random_shuffle(id+1, id+n+1);

	int N=min(n, 1000);

	ask(st);

	if(p[st].x>=x) answer(p[st].x);

	for(int i=1; i<=N; i++){

		ask(id[i]);

		int u=p[id[i]].x;

		if(u<x and u>p[st].x)	st=id[i];

	}

	for(int i=1; i<1000; i++){

		ask(st);

		if(p[st].x>=x) answer(p[st].x);

		if(p[st].x==-1) answer(-1);

		st=p[st].y;

	}

}


#define ONLINE_JUDGE
#include <bits/stdc++.h>

using namespace std;

#define NN 55555

bool vst[NN];

int main(){

	srand(time(NULL));

	int N, X, st, p, val;

	cin>>N>>st>>X;

	printf("? %d\n", st);

	fflush(stdout);

	scanf("%d%d", &val, &p);

	if (X<val) {

		puts("! -1");

		fflush(stdout);

		return 0;

	}

	vst[st]=1;

	int mm=val, pos=st;

	int step=13331, n=st;

	for (int i=0; i<1000 && i<N; i++) {

		int n=(n+step)%N;

		if(n==0) n=N;

		printf("? %d\n", n);fflush(stdout);

		scanf("%d%d", &val, &p);

		if (val>X) continue;

		if (val==X) {

			printf("! %d\n", X);

			fflush(stdout);

			return 0;

		}

		if (X-val<X-mm) {

			mm=val;

			pos=n;

		}

	}

	st=pos;

	for (int i=0; i<990 && i<N; i++) {

		printf("? %d\n", st);fflush(stdout);

		scanf("%d%d", &val, &p);

		if (val>=X) {

			printf("! %d\n", val);

			fflush(stdout);

			return 0;

		}

		if (p<0) {

			puts("! -1");

			fflush(stdout);

			return 0;

		}

		st=p;

	}

	puts("! -1");

	fflush(stdout);

	return 0;

}


#include<bits/stdc++.h>

#define x first

#define y second

#define pb push_back

#define inf 0x3f3f3f3f3f

#define mod 10000000007

#define sq(x) ((x)*(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if (a<b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a>b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T>inline void printsp(T x) {print(x); putchar(' ');}

template<class T>inline void println(T x) {print(x); putchar('\n');}

template<class T, class U>inline void print(T x, U y) {printsp(x); println(y);}

template<class T, class U, class V>inline void print(T x, U y, V z) {printsp(x); printsp(y); println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a*a%m) if (!b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 111111

int id[NN];

pii p[NN];

void ask(int u){

	putchar('?');

	cout<<' ';

	println(u);

	fflush(stdout);

	gn(p[u].x, p[u].y);

}

void answer(int u){

	putchar('!');

	cout<<' ';

	print(u);

	exit(0);

}

int main() {

	int n, st, x;

	gn(n, st, x);

	srand(time(0));

	for(int i=1; i<=n; i++)	id[i]=i;

	random_shuffle(id+1, id+n+1);

	int N=min(n, 1000);

	ask(st);

	if(p[st].x>=x) answer(p[st].x);

	for(int i=1; i<=N; i++){

		ask(id[i]);

		int u=p[id[i]].x;

		if(u<x and u>p[st].x)	st=id[i];

	}

	for(int i=1; i<1000; i++){

		if(!p[st].y)	ask(st);

		if(p[st].x>=x) answer(p[st].x);

		if(p[st].x==-1) answer(-1);

		st=p[st].y;

	}

}