//you cannot mark for urself
//everyone marks for some other guy:
//ambiguity: if everyone marks for one other guy, there needs to be 999998 markers
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define lsb(x) (x&(-x))
#define pii pair<int,int>
#define ss second
#define ff first
#define piii pair<int,pii>
#define debu(x) (cerr << #x << " = "<< x << "\n")
#define debu2(x,y) (cerr << #x << " = "<< x << " " << #y << " = " << y << "\n")
#define debu3(x,y,z) (cerr << #x << " = "<< x << " " << #y << " = " << y << " " << #z << " = " << z<< "\n")
#define bitout(x,y) {\
cerr << #x << " : ";\
for (int justforbits = y; justforbits >=0; justforbits--)cout << (((1 << justforbits) & x)>=1);\
cout << "\n";\
}
#define rangeout(j,rangestart,rangeend) {\
cerr << "outputting " << #j<< ":\n";\
for (int forrang = rangestart; forrang <= rangeend; forrang++)cerr << j[forrang] << " ";\
cerr<<"\n";\
}
#define c1 {cerr << "Checkpoint 1! \n\n";cerr.flush();}
#define c2 {cerr << "Checkpoint 2! \n\n";cerr.flush();}
#define c3 {cerr << "Checkpoint 3! \n\n";cerr.flush();}
#define c4 {cerr << "Checkpoint 4! \n\n";cerr.flush();}
#define vi vector<int>
#define vpii vector<pii>
#define fr(i,x,y) for(int i=x;i<=y;i++)
int p,n;
//if info is repeated twice it is reliable
int ip(){int x;cin>>x;return x;}
void op(int x){cout<<x<<endl;cout.flush();}
void op2(int x, int y){cout<<x<<" "<<y<<endl;cout.flush();}
void Alice()
{
int x=0,t1=0;
for(int i=1;i<n;i++){t1=ip();op(x);x++;}
}
void Bob()
{
vector<int>cnt(n+1,0);
vi ans;int t1;
fr(i,1,n)
{
cin>>t1;
if(cnt[t1]!=0){ans.pb(i);ans.pb(cnt[t1]);}
cnt[t1]=i;
}
op2(ans[0],ans[1]);
}
signed main()
{
int t1,t2,t3,t4;
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>p>>n;
if(p==1)
{
Alice();
}
else
{
Bob();
}
}