#include<bits/stdc++.h>
using namespace std;
set<long long> s;
map<long long,long long> mp,mp1;
vector<long long> v;
set<long long>::iterator it,it1;
long long a[100000],b[100000],arr[100000];
int main()
{
	long long i,j,k,l,m,n,c=0,h,x,y,z,t,ans=0,sum=0,max1=0;
    cin>>n;
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++)
    {
    	cin>>m;
    	s.insert(m);
    	a[i]=m;
    	mp1[m]=1;
    }
    #include<bits/stdc++.h>
using namespace std;
set<long long> s;
map<long long,long long> mp,mp1;
vector<long long> v;
set<long long>::iterator it,it1;
long long a[100000],b[100000],arr[100000];
int main()
{
	long long i,j,k,l,m,n,c=0,h,x,y,z,t,ans=0,sum=0,max1=0;
    cin>>n;
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++)
    {
    	cin>>m;
    	s.insert(m);
    	a[i]=m;
    	mp1[m]=1;
    }
    if(s.size()==1)
    {
    	if(*s.begin()==1)
    		m=2;
    	else
    		m=1;
    }
    else
    {
    for(it=s.begin();it!=s.end();it++)
    {
    	//cout<<*it<<" ";
        arr[c++]=*it;
    }
    m=0;
    for(i=0;i<c-1;i++)
    {
    	if(arr[i+1]-arr[i]>1)
    		{
              m=arr[i]+1;
              break;
    		}
    }
    if(m==0)
    	m=arr[c-1];
}
sort(a,a+n);
    for(i=0;i<n;i++)
    {
    	if(m==a[i])
    		{
    			m++;
    		}
    	if(a[i]>m)
    		{
    			m++;
    			mp[a[i]]=1;
    		}

    }
    cout<<m<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set<long long> s;
map<long long,long long> mp,mp1;
vector<long long> v;
set<long long>::iterator it,it1;
long long a[100000],b[100000],arr[100000];
int main()
{
	long long i,j,k,l,m,n,c=0,h,x,y,z,t,ans=0,sum=0,max1=0;
    cin>>n;
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++)
    {
    	cin>>m;
    	s.insert(m);
    	a[i]=m;
    	mp1[m]=1;
    }
    if(s.size()==1)
    {
    	if(*s.begin()==1)
    		m=2;
    	else
    		m=1;
    }
    else
    {
    for(it=s.begin();it!=s.end();it++)
    {
    	//cout<<*it<<" ";
        arr[c++]=*it;
    }
    m=0;
    for(i=0;i<c-1;i++)
    {
    	if(arr[i+1]-arr[i]>1)
    		{
              m=arr[i]+1;
              break;
    		}
    }
    if(m==0)
    	m=arr[c-1];
}
m=1;
    for(i=0;i<n;i++)
    {
    	if(m==a[i])
    		{
    			m++;
    		}
    	if(a[i]>m)
    		{
    			m++;
    			mp[a[i]]=1;
    		}

    }
    cout<<m<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set<long long> s;
map<long long,long long> mp,mp1;
vector<long long> v;
set<long long>::iterator it,it1;
long long a[100000],b[100000],arr[100000];
int main()
{
	long long i,j,k,l,m,n,c=0,h,x,y,z,t,ans=0,sum=0,max1=0;
    cin>>n;
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++)
    {
    	cin>>m;
    	s.insert(m);
    	a[i]=m;
    	mp1[m]=1;
    }
    if(s.size()==1)
    {
    	if(*s.begin()==1)
    		m=2;
    	else
    		m=1;
    }
    else
    {
    for(it=s.begin();it!=s.end();it++)
    {
    	//cout<<*it<<" ";
        arr[c++]=*it;
    }
    m=0;
    for(i=0;i<c-1;i++)
    {
    	if(arr[i+1]-arr[i]>1)
    		{
              m=arr[i]+1;
              break;
    		}
    }
    if(m==0)
    	m=arr[c-1];
}
    for(i=0;i<n;i++)
    {
    	if(m==a[i]&&mp1[m]==1)
    		{
    			m++;
    			mp1[m]=0;
    		}
    	if(a[i]>m)
    		{
    			m++;
    			mp[a[i]]=1;
    		}

    }
    cout<<m<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set<long long> s;
map<long long,long long> mp,mp1;
vector<long long> v;
set<long long>::iterator it,it1;
long long a[100000],b[100000],arr[100000];
int main()
{
	long long i,j,k,l,m,n,c=0,h,x,y,z,t,ans=0,sum=0,max1=0;
    cin>>n;
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++)
    {
    	cin>>m;
    	s.insert(m);
    	a[i]=m;
    	mp1[m]=1;
    }
    if(s.size()==1)
    {
    	if(*s.begin()==1)
    		m=2;
    	else
    		m=1;
    }
    else
    {
    for(it=s.begin();it!=s.end();it++)
    {
    	//cout<<*it<<" ";
        arr[c++]=*it;
    }
    m=0;
    for(i=0;i<c-1;i++)
    {
    	if(arr[i+1]-arr[i]>1)
    		{
              m=arr[i]+1;
              break;
    		}
    }
    if(m==0)
    	m=arr[c-1];
    if(mp1[1]==0)
    	m=1;
}
    for(i=0;i<n;i++)
    {
    	if(m==a[i])
    		{
    			m++;
    		}
    	if(a[i]>m)
    		{
    			m++;
    			mp[a[i]]=1;
    		}

    }
    cout<<m<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set<long long> s;
map<long long,long long> mp,mp1;
vector<long long> v;
set<long long>::iterator it,it1;
long long a[100000],b[100000],arr[100000];
int main()
{
	long long i,j,k,l,m,n,c=0,h,x,y,z,t,ans=0,sum=0,max1=0;
    cin>>n;
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++)
    {
    	cin>>m;
    	s.insert(m);
    	a[i]=m;
    	mp1[m]=1;
    }
    if(s.size()==1)
    {
    	if(*s.begin()==1)
    		m=2;
    	else
    		m=1;
    }
    else
    {
    for(it=s.begin();it!=s.end();it++)
    {
    	//cout<<*it<<" ";
        arr[c++]=*it;
    }
    m=0;
    for(i=0;i<c-1;i++)
    {
    	if(arr[i+1]-arr[i]>1)
    		{
              m=arr[i]+1;
              break;
    		}
    }
    if(m==0)
    	m=arr[c-1];
    if(mp1[1]==0)
    	m=1;
}
sort(a,a+n);
    for(i=0;i<n;i++)
    {
    	if(m==a[i])
    		{
    			m++;
    		}
    	if(a[i]>m)
    		{
    			m++;
    			mp[a[i]]=1;
    		}

    }
    cout<<m<<endl;
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <iomanip>
#include <assert.h>

#ifdef DK

#include "Tool.hh"

#endif

using namespace std;

#ifdef DK
const int MAX = 33;
#else
const int MAX = (const int) (1e5 + 11);
#endif

int N;
int A[MAX];

static void solve(std::int32_t test) {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A, A + N);
    int res = 1;
    for (int i = 0; i < N; ++i) {
        if (A[i] >= res)
            res++;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cout << setprecision(12) << fixed;
#ifdef DK
    tool::run_task(tool::Task::B, solve);
#else
    solve(0);
#endif
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <iomanip>
#include <assert.h>

#ifdef DK

#include "Tool.hh"

#endif

using namespace std;

#ifdef DK
const int MAX = 33;
#else
const int MAX = (const int) (1e5 + 11);
#endif

int N;
int A[MAX];

static void solve(std::int32_t test) {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    if (N == 1)
    {
        if (A[0] == 1)
            cout << 2;
        else
            cout << 1;
        return;
    }
    sort(A, A + N);
    for (int i = 1; i < N; ++i) {
        if (A[i - 1] + 1 < A[i])
            A[i] = A[i - 1] + 1;
    }
    cout << A[N - 1] + 1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cout << setprecision(12) << fixed;
#ifdef DK
    tool::run_task(tool::Task::B, solve);
#else
    solve(0);
#endif
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <iomanip>
#include <assert.h>

#ifdef DK

#include "Tool.hh"

#endif

using namespace std;

#ifdef DK
const int MAX = 33;
#else
const int MAX = (const int) (1e5 + 11);
#endif

int N;
int A[MAX];

static void solve(std::int32_t test) {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A, A + N);
    if (A[0] != 1)
        A[0] = 1;
    for (int i = 1; i < N; ++i) {
        if (A[i - 1] + 1 < A[i])
            A[i] = A[i - 1] + 1;
    }
    cout << A[N - 1] + 1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cout << setprecision(12) << fixed;
#ifdef DK
    tool::run_task(tool::Task::B, solve);
#else
    solve(0);
#endif
    return 0;
}


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

const int N = 100000 + 77;
int n , m , l = 0 , r = 1e9 + 1 , ts = 1 , inf = 1e9;
bool t[N];
int main(){
	scanf("%d %d" , & m , & n);inf = m;r = m + 1;
	for(int i = 1;i <= n;i ++){
		printf("%d\n" , inf);fflush(stdout);
		int p;scanf("%d" , & p);
		if(p == 0){return 0;}
		if(p == 1){t[i] = 1;}
	}
	while(r - l > 1){
		int mid = (l + r);mid >>= 1;
		printf("%d\n" , mid);fflush(stdout);
		int p;scanf("%d" , & p);
		if(p == 0){return 0;}
		if((t[ts] && p == - 1) || (!t[ts] && p == 1)){
			l = mid;
		}
		else{
			r = mid;
		}
		ts ++;
	}
	return 0;
}


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

const int N = 100000 + 77 , inf = 2e9;
int n , m , l = 1 , r = 1e9 + 1 , ts = 1;
bool t[N];
int lst;
int main(){
	cin >> m >> n;
	for(int i = 1;i <= n;i ++){
		cout << inf << endl;
		int p;cin >> p;
		if(p == 1){t[i] = 1;}
	}
	r = m + 1;
	while(r - l > 1){
		int mid = (l + r);mid >>= 1;
		cout << mid << endl;
		int p;cin >> p;
		if(p == 0){return 0;}
		if(t[ts] && p == - 1){
			l = mid;
			lst = 0;
		}
		else{
			r = mid;
			lst = 1;
		}
		ts ++;
	}
	if(lst == 0){
		cout << r << endl;
		int p;cin >> p;
	}
	else{
		cout << l << endl;
		int p;cin >> p;
	}
	return 0;
}


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

const int N = 100000 + 77;
int n , m , l = 0 , r = 1e9 + 1 , ts = 1 , inf = 1e9;
bool t[N];
int main(){
	scanf("%d %d" , & m , & n);inf = m;
	for(int i = 1;i <= n;i ++){
		printf("%d\n" , inf);fflush(stdout);
		int p;scanf("%d" , & p);
		if(p == 0){return 0;}
		if(p == 1){t[i] = 1;}
	}
	r = m + 1;
	while(r - l > 1){
		int mid = (l + r);mid >>= 1;
		printf("%d\n" , mid);fflush(stdout);
		int p;scanf("%d" , & p);
		if(p == 0){return 0;}
		if(t[ts] && p == - 1){
			l = mid;
		}
		else{
			r = mid;
		}
		ts ++;
	}

	return 0;
}


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

const int N = 100000 + 77 , inf = 2147483647;
int n , m , l = 1 , r = 1e9 + 1 , ts = 1;
bool t[N];
int lst;
int main(){
	cin >> m >> n;
	for(int i = 1;i <= n;i ++){
		cout << inf << endl;
		int p;cin >> p;
		if(p == 1){t[i] = 1;}
	}
	r = m + 1;
	while(r - l > 1){
		int mid = (l + r);mid >>= 1;
		cout << mid << endl;
		int p;cin >> p;
		if(p == 0){return 0;}
		if(t[ts] && p == - 1){
			l = mid;
			lst = 0;
		}
		else{
			r = mid;
			lst = 1;
		}
		ts ++;
	}
	if(lst == 0){
		cout << r << endl;
		int p;cin >> p;
	}
	else{
		cout << l << endl;
		int p;cin >> p;
	}
	return 0;
}


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

const int N = 100000 + 77 , inf = 2e9;
int n , m , l = 0 , r = 1e9 + 1 , ts = 1;
bool t[N];
int main(){
	scanf("%d %d" , & m , & n);
	for(int i = 1;i <= n;i ++){
		printf("%d\n" , inf);fflush(stdout);
		int p;scanf("%d" , & p);
		if(p == 1){t[i] = 1;}
	}
	r = m + 1;
	while(r - l > 1){
		int mid = (l + r);mid >>= 1;
		printf("%d\n" , mid);fflush(stdout);
		int p;scanf("%d" , & p);
		if(p == 0){return 0;}
		if(t[ts] && p == - 1){
			l = mid;
		}
		else{
			r = mid;
		}
		ts ++;
	}

	return 0;
}


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

const int N = 100000 + 77 , inf = 2147483647;
int n , m , l = 0 , r = 1e9 + 1 , ts = 1;
bool t[N];
int main(){
	cin >> m >> n;
	for(int i = 1;i <= n;i ++){
		cout << inf << endl;
		int p;cin >> p;
		if(p == 1){t[i] = 1;}
	}
	r = m + 1;
	while(r - l > 1){
		int mid = (l + r);mid >>= 1;
		cout << mid << endl;
		int p;cin >> p;
		if(p == 0){return 0;}
		if(t[ts] && p == - 1){
			l = mid;
		}
		else{
			r = mid;
		}
		ts ++;
	}
	return 0;
}


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

const int N = 100000 + 77 , inf = 2147483647;
int n , m , l = 0 , r = 1e9 + 1 , ts = 1;
bool t[N];
int main(){
	cin >> m >> n;
	for(int i = 1;i <= n;i ++){
		cout << inf << endl;
		int p;cin >> p;
		if(p == 1){t[i] = 1;}
	}
	while(r - l > 1){
		int mid = (l + r);mid >>= 1;
		cout << mid << endl;
		int p;cin >> p;
		if(p == 0){return 0;}
		if(t[ts] && p == - 1){
			r = mid;
		}
		else{
			l = mid;
		}
		ts ++;
	}
	return 0;
}


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

const int N = 100000 + 77 , inf = 2e9;
int n , m , l = 0 , r = 1e9 + 1 , ts = 1;
bool t[N];
int main(){
	cin >> m >> n;
	for(int i = 1;i <= n;i ++){
		cout << inf << endl;
		int p;cin >> p;
		if(p == 1){t[i] = 1;}
	}
	r = m + 1;
	while(r - l > 1){
		int mid = (l + r);mid >>= 1;
		cout << mid << endl;
		int p;cin >> p;
		if(p == 0){return 0;}
		if(t[ts] && p == - 1){
			l = mid;
		}
		else{
			r = mid;
		}
		ts ++;
	}

	return 0;
}


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

const int N = 100000 + 77;
int n , m , l = 0 , r = 1e9 + 1 , ts = 1 , inf = 1e9;
bool t[N];
int main(){
	scanf("%d %d" , & m , & n);inf = m;r = m + 1;
	for(int i = 1;i <= n;i ++){
		printf("%d\n" , inf);fflush(stdout);
		int p;scanf("%d" , & p);
		if(p == 0){return 0;}
		if(p == 1){t[i] = 1;}
	}
	while(r - l > 1){
		int mid = (l + r);mid >>= 1;
		printf("%d\n" , mid);fflush(stdout);
		int p;scanf("%d" , & p);
		if(p == 0){return 0;}
		if((t[ts] && p == - 1) || (!t[ts] && p == 1)){
			l = mid;
		}
		else{
			r = mid;
		}
		ts ++;
		if(ts > n){ts -= n;}
	}
	return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  printf("%d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1) != 1;
  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }
    if(clock() > 100){
      cout << lf << " " << rg << "\n";
      fflush(stdout);
    }
    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  printf("%d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1) != 1;
  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }
    if(clock() > 100){
      cout << lf << " " << rg << "\n";
    }
    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  cout << x << endl;
  cin >> x;
  return x;
}

int main(){
  cin >> m >> n;
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1);
    if(!p[i]){
      return 0;
    }
    p[i] = p[i] != 1;
  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }
    int mid = (lf + rg) >> 1;
    int z = guess(mid);
    if(!z){
      exit(0);
    }
    if(p[i] == 1){
      z *= -1;
    }
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }

  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N], cnt;

int guess(int x){
  ++cnt;
  printf("%d\n", x);
  fflush(stdout);
  if(cnt > 60){
    exit(-1);
  }
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    p[i] = guess((m + 1) / 2);
  }
  int lf, rg;
  if(p[1] == -1){
    lf = 1, rg = (m + 1) / 2 - 1;
  } else{
    lf = (m + 1) / 2 + 1, rg = m;
  }
  while(lf != rg){
    for(int i = 1; i <= n; ++i){
      if(lf == rg){
        guess(lf);
        guess(m - lf + 1);
        exit(0);
      }
      if(rg - lf == 1){
        guess(lf);
        guess(rg);
        guess(m - lf + 1);
        guess(m - rg + 1);
        exit(0);
      }
      if(p[i] == -1){
        int mid = (lf + rg) >> 1;
        if(guess(mid) == -1){
          rg = mid - 1;
        } else{
          lf = mid + 1;
        }
      } else{
        int mid = (lf + rg) >> 1;
        if(guess(mid) == -1){
          lf = mid + 1;
        } else{
          rg = mid - 1;
        }
      }
    }

  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  printf("%d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    if(m == 10){
      cout << "HERE\n";
    }
    p[i] = guess(1) != 1;
  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }

    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  printf("%d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1) != 1;
  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }
    if(n == 10){
      cout << lf << " " << rg << "\n";
    }
    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  printf("%d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1) != 1;
    if(n == 10){
      cout << "HERE\n";
    }
  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }
    if(n == 10){
      cout << lf << " " << rg << "\n";
    }
    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  printf("%d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  if(m == 10){
    cout << "HERE\n";
  }
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1) != 1;
  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }

    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N], cnt;

int guess(int x){
  ++cnt;
  printf("%d\n", x);
  fflush(stdout);
  if(cnt > 60){
    exit(-1);
  }
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    p[i] = guess((m + 1) / 2);
  }
  int lf, rg;
  if(p[1] == -1){
    lf = 1, rg = (m + 1) / 2 - 1;
  } else{
    lf = (m + 1) / 2 + 1, rg = m;
  }
  while(lf != rg){
    for(int i = 1; i <= n; ++i){
      if(lf == rg){
        guess(lf);
        guess(m - lf + 1);
        exit(0);
      }
      if(p[i] == -1){
        int mid = (lf + rg) >> 1;
        if(guess(mid) == -1){
          rg = mid - 1;
        } else{
          lf = mid + 1;
        }
      } else{
        int mid = (lf + rg) >> 1;
        if(guess(mid) == -1){
          lf = mid + 1;
        } else{
          rg = mid - 1;
        }
      }
    }

  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  printf("%d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1) != 1;
  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }
    if(m == 10){
      cout << lf << " " << rg << "\n";
    }
    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  printf("%d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    p[i] = guess((m + 1) / 2);
  }
  int lf, rg;
  if(p[1] == -1){
    lf = 1, rg = (m + 1) / 2 - 1;
  } else{
    lf = (m + 1) / 2 + 1, rg = m;
  }
  while(lf != rg){
    for(int i = 1; i <= n; ++i){
      if(lf == rg){
        guess(lf);
        guess(m - lf + 1);
        exit(0);
      }
      if(p[i] == -1){
        int mid = (lf + rg) >> 1;
        if(guess(mid) == -1){
          rg = mid - 1;
        } else{
          lf = mid + 1;
        }
      } else{
        int mid = (lf + rg) >> 1;
        if(guess(mid) == -1){
          lf = mid + 1;
        } else{
          rg = mid - 1;
        }
      }
    }

  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  printf("%d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1) != 1;
  }
  int lf = 1, rg = m;
  for(int i = 1; i <= n; ++i){
    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }
  guess(lf);
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  cout << x << endl;
  cin >> x;
  return x;
}

int main(){
  cin >> m >> n;
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1);
    if(!p[i]){
      return 0;
    }
    p[i] = p[i] != 1;

  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }
    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(!z){
      exit(0);
    }
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }

  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  printf("%d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  scanf("%d %d", &m, &n);
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1) != 1;
  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }
    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 aasjdladljskdj

using namespace std;

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

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 9;

int m, n;
int p[N];

int guess(int x){
  cout << x << endl;
  cin >> x;
  if(x == 0){
    exit(0);
  }
  return x;
}

int main(){
  cin >> m >> n;
  for(int i = 1; i <= n; ++i){
    p[i] = guess(1) != 1;
  }
  int lf = 1, rg = m;
  for(int i = 1; ; ++i){
    if(i == n + 1){
      i = 1;
    }
    if(lf == rg){
      guess(lf);
    }
    int mid = (lf + rg) >> 1;
    int z = guess(mid) * (p[i] * -1);
    if(z == -1){
      rg = mid - 1;
    } else{
      lf = mid + 1;
    }
  }

  return 0;
}


#include<bits/stdc++.h>
#define fls fflush(stdout)
using namespace std;
int a[35];
int main ()
{
    int m,n,tmp;
    scanf("%d%d",&m,&n);
    for(int i=1;i<=n;i++)
    {
        printf("1\n"); fls;
        scanf("%d",&tmp);
        if(!tmp)
        {
            printf("1\n");
            fls; return 0;
        }
        if(tmp==1) a[i]=1;
        if(tmp==-1) a[i]=-1;
    }
    int l=1,r=1000000000;
    int cnt=0;
    while(l<=r)
    {
        cnt++;
        int mid=(l+r)>>1;
        printf("%d\n",mid); fls;
        scanf("%d",&tmp); tmp*=a[cnt];
        if(tmp==1) l=mid+1;
        if(tmp==-1) r=mid-1;
        if(tmp==0)
        {
            printf("%d\n",mid);
            fls; return 0;
        }
    }
}


#include<bits/stdc++.h>
#define fls fflush(stdout)
using namespace std;
int a[35];
int main ()
{
    int m,n,tmp;
    scanf("%d%d",&m,&n);
    for(int i=1;i<=n;i++)
    {
        printf("1\n"); fls;
        scanf("%d",&tmp);
        if(!tmp) return 0;
        if(tmp==1) a[i]=1;
        if(tmp==-1) a[i]=-1;
    }
    int l=1,r=m;
    int cnt=0;
    while(l<=r)
    {
        cnt++;
        int mid=(l+r)>>1;
        printf("%d\n",mid); fls;
        scanf("%d",&tmp); tmp*=a[cnt];
        if(tmp==1) l=mid+1;
        if(tmp==-1) r=mid-1;
        if(tmp==0) return 0;
    }
}


#include<bits/stdc++.h>
#define fls fflush(stdout)
using namespace std;
int a[35];
int main ()
{
    int m,n,tmp;
    scanf("%d%d",&m,&n);
    for(int i=1;i<=n;i++)
    {
        printf("1\n"); fls;
        scanf("%d",&tmp);
        if(!tmp) return 0;
        if(tmp==1) a[i]=1;
        if(tmp==-1) a[i]=-1;
    }
    int l=1,r=m;
    int cnt=0;
    while(l<=r)
    {
        cnt++; if(cnt>n) cnt-=n;
        int mid=(l+r)>>1;
        printf("%d\n",mid); fls;
        scanf("%d",&tmp); tmp*=a[cnt];
        if(tmp==1) l=mid+1;
        if(tmp==-1) r=mid-1;
        if(tmp==0) return 0;
    }
}


//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <map>
#include <set>
#include <ctime>
#include <random>
#include <chrono>
// #include<windows.h>
// #define debug true
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, m, l, r;
int query(int num)
{
    cout << num << endl;
    int v;
    cin >> v;
    if (v == 0)
    {
        exit(0);
    }
    return v;
}
int f[35], cnt; //-1 is cheat
signed main()
{
    ios::sync_with_stdio(false);
    cin >> m >> n;
    for (int i = 1; i <= n; ++i)
    {
        f[i] = query(1);
    }
    l = 1;
    r = m;
    while (l < r)
    {
        int mid = (l + r) >> 1;
        if (query(mid) * f[++cnt] == 1)
        {
            l = mid + 1;
        }
        else
        {
            r = mid - 1;
        }
    }
    return 0;
}


//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <map>
#include <set>
#include <ctime>
#include <random>
#include <chrono>
// #include<windows.h>
// #define debug true
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, m, l, r;
int query(int num)
{
    cout << num << endl;
    int v;
    cin >> v;
    if (v == 0)
    {
        exit(0);
    }
    return v;
}
int f[35], cnt; //-1 is cheat
signed main()
{
    ios::sync_with_stdio(false);
    cin >> m >> n;
    for (int i = 1; i <= n; ++i)
    {
        f[i] = query(1);
    }
    l = 1;
    r = m;
    while (l < r)
    {
        int mid = (l + r) >> 1;
        if (query(mid) * f[++cnt] == 1)
        {
            l = mid + 1;
        }
        else
        {
            r = mid;
        }
    }
    query(l);
    return 0;
}


//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <map>
#include <set>
#include <ctime>
#include <random>
#include <chrono>
// #include<windows.h>
// #define debug true
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, m, l, r;
int query(int num)
{
    cout << num << endl;
    int v;
    cin >> v;
    if (v == 0)
    {
        exit(0);
    }
    return v;
}
int f[35], cnt; //-1 is cheat
signed main()
{
    ios::sync_with_stdio(false);
    cin >> m >> n;
    for (int i = 0; i < n; ++i)
    {
        f[i] = query(1);
    }
    l = 1;
    r = m;
    while (l < r)
    {
        int mid = (l + r) >> 1;
        if (query(mid) * f[cnt++ % n] == 1)
        {
            l = mid + 1;
        }
        else
        {
            r = mid - 1;
        }
    }
    query(l);
    return 0;
}


//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <map>
#include <set>
#include <ctime>
#include <random>
#include <chrono>
// #include<windows.h>
// #define debug true
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, m, l, r;
int query(int num)
{
    cout << num << endl;
    int v;
    cin >> v;
    if (v == 0)
    {
        exit(0);
    }
    return v;
}
int f[35], cnt; //-1 is cheat
signed main()
{
    ios::sync_with_stdio(false);
    cin >> m >> n;
    for (int i = 1; i <= n; ++i)
    {
        f[i] = query(1);
    }
    l = 1;
    r = m;
    while (l < r)
    {
        int mid = (l + r) >> 1;
        if (query(mid) * f[++cnt] == 1)
        {
            l = mid + 1;
        }
        else
        {
            r = mid - 1;
        }
    }
    query(l);
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

int a[31];

int main()
{
	int n,m,i;scanf("%d%d",&m,&n);
	for(i=0;i<n;i++){printf("0\n");fflush(stdout);scanf("%d",&a[i]);}
	int l=1,r=m,mid,x;
	for(i=0;l<=r;i++){
		mid=(l+r)>>1;printf("%d\n",mid);fflush(stdout);scanf("%d",&x);
		if(x*a[i%n]==0)return 0;
		if(x*a[i%n]==1)l=mid+1;else r=mid-1;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

int a[31];

int main()
{
	int n,m,i;scanf("%d%d",&m,&n);
	for(i=0;i<n;i++){printf("0\n");fflush(stdout);scanf("%d",&a[i]);}
	int l=1,r=m,mid,x;
	for(i=0;l<=r;i++){
		mid=(l+r)>>1;printf("%d\n",mid);fflush(stdout);scanf("%d",&x);
		if(x*a[i%n]==0){printf("%d\n",mid);fflush(stdout);return 0;}
		if(x*a[i%n]==1)l=mid+1;else r=mid-1;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

int a[31];

int main()
{
	int n,m,i;scanf("%d%d",&m,&n);
	for(i=1;i<=n;i++){printf("0\n");fflush(stdout);scanf("%d",a[i]);}
	int l=1,r=m,mid,x;
	for(i=1;l<=r;i++){
		mid=(l+r)>>1;printf("%d\n",mid);fflush(stdout);scanf("%d",&x);
		if(x*a[i%n]==0)return 0;
		if(x*a[i%n]==1)l=mid+1;else r=mid-1;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

int a[31];

int main()
{
	int n,m,i;scanf("%d%d",&m,&n);
	for(i=0;i<n;i++){printf("1\n");fflush(stdout);scanf("%d",&a[i]);}
	int l=1,r=m,mid,x;
	for(i=0;l<=r;i++){
		mid=(l+r)>>1;printf("%d\n",mid);fflush(stdout);scanf("%d",&x);
		if(x*a[i%n]==0){printf("%d\n",mid);fflush(stdout);return 0;}
		if(x*a[i%n]==1)l=mid+1;else r=mid-1;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

int a[31];

int main()
{
	int n,m,i;scanf("%d%d",&m,&n);
	for(i=1;i<=n;i++){printf("0\n");fflush(stdout);scanf("%d",&a[i]);}
	int l=1,r=m,mid,x;
	for(i=1;l<=r;i++){
		mid=(l+r)>>1;printf("%d\n",mid);fflush(stdout);scanf("%d",&x);
		if(x*a[i%n]==0)return 0;
		if(x*a[i%n]==1)l=mid+1;else r=mid-1;
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>

int a[60];
int n, m;

using namespace std;

int main()
{
    cin >> n >> m;

    for (int i = 0; i < m; ++i)
    {
        cout << n << endl;
        fflush(stdout);
        cin >> a[i];
        if (a[i] == 0) return 0;
    }

    int l = 1, r = n, mid, re, i;
    i = 0;
    while (true)
    {
        mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        cin >> re;
        if (re == 0) return 0;
        if (re * a[i] == -1) r = mid - 1; else l = mid + 1;
        i = (i + 1) % m;
    }
}


#include <iostream>
#include <cstdio>
#include <algorithm>

int a[60];
int n, m;

using namespace std;

int main()
{
    cin >> n >> m;

    for (int i = 0; i < m; ++i)
    {
        cout << n << endl;
        fflush(stdout);
        cin >> a[i];
        if (a[i] == 0) return 0;
    }

    int l = 1, r = n, mid, re, i;
    i = 0;
    while (true)
    {
        mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        cin >> re;
        if (re == 0) return 0;
        if (re * a[i] == -1) l = mid + 1; else r = mid - 1;
        i = (i + 1) % m;
    }
}


#include <iostream>
#include <cstdio>
#include <algorithm>

int a[60];
int n, m;

using namespace std;

int main()
{
    cin >> n >> m;

    for (int i = 0; i < m; ++i)
    {
        cout << n << endl;
        fflush(stdout);
        cin >> a[i];
        if (a[i] == 0) return 0;
    }

    int l = 1, r = n, mid, re, i;
    i = 0;
    while (true)
    {
        mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        cin >> re;
        if (re == 0) return 0;
        if (re * a[i] == -1) l = mid - 1; else r = mid + 1;
        i = (i + 1) % m;
    }
}


#include <bits/stdc++.h>

using namespace std;

int const N = 1e3 + 5;

int m, n;
int type[N];

int main()
{
   // freopen("inp.txt", "r", stdin);
    cin >> m >> n;
    fflush(stdout);
    for (int i = 0; i < n; i++) {
        cout << 1 << endl;
        fflush(stdout);
        cin >> type[i];
        fflush(stdout);
        if (type[i] == 0) {
            return 0;
        }
    }

    int l = 1;
    int r = m;

    for (int i = 0; i < 60 - n; i++) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        int ans;
        cin >> ans;
        fflush(stdout);
        ans *= type[i % n];
        if (ans == 0) {
            return 0;
        }
        assert(ans == -1 || ans == 1);
        if (ans == -1) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int const N = 1e3 + 5;

int m, n;
int type[N];

int main()
{
   // freopen("inp.txt", "r", stdin);
    cin >> m >> n;
    for (int i = 0; i < n; i++) {
        cout << 1 << endl;
        fflush(stdout);
        cin >> type[i];
        if (type[i] == 0) {
            return 0;
        }
    }

    int l = 1;
    int r = m;

    for (int i = 0; i < 60 - n; i++) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        int ans;
        cin >> ans;
        ans *= type[i % n];
        if (ans == 0) {
            return 0;
        }
        assert(ans != -2);
        if (ans == -1) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int const N = 1e3 + 5;

int m, n;
int type[N];

int main()
{
 //   freopen("inp.txt", "r", stdin);
    cin >> m >> n;
    for (int i = 0; i < n; i++) {
        cout << 0 << endl;
        fflush(stdout);
        cin >> type[i];
        if (type[i] == 0) {
            type[i] = -1;
        }
    }

    int l = 1;
    int r = m;

    for (int i = 0; i < 60 - n; i++) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        int ans;
        cin >> ans;
        ans *= type[i % n];
        if (ans == 0) {
            return 0;
        }
        assert(ans != -2);
        if (ans == -1) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int const N = 1e3 + 5;

int m, n;
int type[N];

int main()
{
  //  freopen("inp.txt", "r", stdin);
    cin >> m >> n;
    for (int i = 1; i <= n; i++) {
        cout << 1 << endl;
        fflush(stdout);
        cin >> type[i];
    }

    int l = 1;
    int r = m;

    for (int i = 1; i <= 60 - n; i++) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        int ans;
        cin >> ans;
        ans *= type[i];
        if (ans == 0) {
            return 0;
        }
        if (ans == 1) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int const N = 1e3 + 5;

int m, n;
int type[N];

int main()
{
   // freopen("inp.txt", "r", stdin);
    cin >> m >> n;
    fflush(stdout);
    for (int i = 0; i < n; i++) {
        cout << 1 << endl;
        fflush(stdout);
        cin >> type[i];
        fflush(stdout);
        if (type[i] == 0) {
            exit(0);
        }
    }

    int l = 1;
    int r = m;

    for (int i = 0; i < 60 - n; i++) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        int ans;
        cin >> ans;
        fflush(stdout);
        ans *= type[i % n];
        if (ans == 0) {
            exit(0);
        }
        assert(ans == -1 || ans == 1);
        if (ans == -1) {
            r = mid - 1;
        }
        else {
            l = mid + 1;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int const N = 1e3 + 5;

int m, n;
int type[N];

int main()
{
   // freopen("inp.txt", "r", stdin);
    cin >> m >> n;
    for (int i = 0; i < n; i++) {
        cout << 1 << endl;
        fflush(stdout);
        cin >> type[i];
        if (type[i] == 0) {
            type[i] = -1;
        }
    }

    int l = 1;
    int r = m;

    for (int i = 0; i < 60 - n; i++) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        int ans;
        cin >> ans;
        ans *= type[i % n];
        if (ans == 0) {
            return 0;
        }
        if (ans == 1) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int const N = 1e3 + 5;

int m, n;
int type[N];

int main()
{
  //  freopen("inp.txt", "r", stdin);
    cin >> m >> n;
    for (int i = 0; i < n; i++) {
        cout << 1 << endl;
        fflush(stdout);
        cin >> type[i];
        if (type[i] == 0) {
            type[i] = -1;
        }
    }

    int l = 1;
    int r = m;

    for (int i = 0; i < 60 - n; i++) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        int ans;
        cin >> ans;
        ans *= type[i % n];
        if (ans == 0) {
            return 0;
        }
        assert(ans != -2);
        if (ans == -1) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int const N = 1e3 + 5;

int m, n;
int type[N];

int main()
{
   // freopen("inp.txt", "r", stdin);
    cin >> m >> n;
    for (int i = 1; i <= n; i++) {
        cout << 1 << endl;
        fflush(stdout);
        cin >> type[i];
        if (type[i] == 0) {
            type[i] = -1;
        }
    }

    int l = 1;
    int r = m;

    for (int i = 1; i <= 60 - n; i++) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        int ans;
        cin >> ans;
        ans *= type[i];
        if (ans == 0) {
            return 0;
        }
        if (ans == 1) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int const N = 1e3 + 5;

int m, n;
int type[N];

int main()
{
 //   freopen("inp.txt", "r", stdin);
    cin >> m >> n;
    for (int i = 1; i <= n; i++) {
        cout << 1 << endl;
        fflush(stdout);
        cin >> type[i];
    }

    int l = 0;
    int r = m + 1;

    for (int i = 1; i <= 60 - n; i++) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        fflush(stdout);
        int ans;
        cin >> ans;
        ans *= type[i];
        if (ans == 0) {
            return 0;
        }
        if (ans == 1) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
}


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

template <typename T> inline void read (T &x) { bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - 48; if (b) x = -x; }
template <typename T> inline void wrip(T x) { if (x > 9) wrip(x / 10); putchar(x%10 + 48); }
template <typename T> inline void write(T x) { if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) { if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
void reads(string &s) { char c; while (!isalpha(c = getchar()) && c != '.'); s = c; while (isalpha(c = getchar()) || c == '.') s += c; }
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef double ld;
typedef pair <int, int> ii;

const ld pi = acos(-1);
const int inf = 1e9;
const int N = 2e5 + 11;
int n, m, res, times, p[N];
int Ask(int x) {
    cout << x << '\n';
    fflush(stdout);
    cin >> x;
    if (!x)
        exit(0);
    return x;
}
int main() {
    read(m);
    read(n);
    for (int i = 1; i <= n; i++)
        p[i] = Ask(1);
    int l = 1, r = m;
    for (int i = 1; i <= n; i++) {
        int mid = l + r >> 1;
        int tmp = p[i] * Ask(mid);
        if (tmp == -1)
            l = mid + 1;
        else
            r = mid - 1;
    }
}


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

template <typename T> inline void read (T &x) { bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - 48; if (b) x = -x; }
template <typename T> inline void wrip(T x) { if (x > 9) wrip(x / 10); putchar(x%10 + 48); }
template <typename T> inline void write(T x) { if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) { if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
void reads(string &s) { char c; while (!isalpha(c = getchar()) && c != '.'); s = c; while (isalpha(c = getchar()) || c == '.') s += c; }
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef double ld;
typedef pair <int, int> ii;

const ld pi = acos(-1);
const int inf = 1e9;
const int N = 2e5 + 11;
int n, m, res, times, p[N];
int Ask(int x) {
    cout << x << '\n';
    fflush(stdout);
    cin >> x;
    if (!x)
        exit(0);
    return x;
}
int main() {
    read(m);
    read(n);
    for (int i = 1; i <= n; i++)
        p[i] = Ask(1);
    int l = 1, r = m;
    while (l <= r) {
        times++;
        if (times > n) times = 1;
        int mid = l + r >> 1;
        int tmp = p[times] * Ask(mid);
        if (tmp == 1)
            l = mid + 1;
        else
            r = mid - 1;
    }
}


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

template <typename T> inline void read (T &x) { bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - 48; if (b) x = -x; }
template <typename T> inline void wrip(T x) { if (x > 9) wrip(x / 10); putchar(x%10 + 48); }
template <typename T> inline void write(T x) { if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) { if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
void reads(string &s) { char c; while (!isalpha(c = getchar()) && c != '.'); s = c; while (isalpha(c = getchar()) || c == '.') s += c; }
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef double ld;
typedef pair <int, int> ii;

const ld pi = acos(-1);
const int inf = 1e9;
const int N = 2e5 + 11;
int n, m, p[N];
int Ask(int x) {
    cout << x << '\n';
    fflush(stdout);
    cin >> x;
    if (!x)
        exit(0);
    return x;
}
int main() {
    read(m);
    read(n);
    for (int i = 1; i <= n; i++)
        p[i] = Ask(1);
    int l = 1, r = m;
    for (int i = 1; i <= n; i++) {
        int mid = l + r >> 1;
        int tmp = p[i] * Ask(mid);
        if (tmp == 1)
            l = mid + 1;
        else
            r = mid - 1;
    }
}


#include <iostream>
#include <cstdio>

using namespace std;

inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
    int x=0;char ch=gc();bool positive=1;
    for(;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
    for(;isdigit(ch);ch=gc())x=x*10+ch-'0';
    return positive?x:-x;
}

inline void write(int x){
    if(x<0)x=-x,putchar('-');
    if(x>9)write(x/10);putchar(x%10+'0');
}

inline void writeln(int x){
    write(x);puts("");
}

int n,m,sum,now,l,r,mid;
bool use[50];

inline int query(int x){
    int now;
    writeln(x);
    fflush(stdout);
    now=read();
    return now;
}

int main(){
    m=read();n=read();
    for(int i=1;i<=n;i++){
        l=query(1);
        if(!l){
            writeln(1);
            return 0;
        }else{
            if(l==1){
                use[i]=false;
            }else{
                use[i]=true;
            }
        }
    }
    l=1;r=m+1;
    while(l+1<r){
        int mid=(l+r)>>1;
        sum++;
        now=query(mid);
        if(!use[sum])now=-now;
        if(!now){
            writeln(mid);
            return 0;
        }else{
            if(now==1){
                r=mid;
            }else{
                l=mid;
            }
        }
    }
    if(!query(l)){
        writeln(l);
        return 0;
    }
    if(!query(r)){
        writeln(r);
        return 0;
    }
    return 0;
}


#include <iostream>
#include <cstdio>

using namespace std;

inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
    int x=0;char ch=gc();bool positive=1;
    for(;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
    for(;isdigit(ch);ch=gc())x=x*10+ch-'0';
    return positive?x:-x;
}

inline void write(int x){
    if(x<0)x=-x,putchar('-');
    if(x>9)write(x/10);putchar(x%10+'0');
}

inline void writeln(int x){
    write(x);puts("");
}

int n,m,sum,now,l,r,mid;
bool use[50];

inline int query(int x){
    int now;
    writeln(x);
    fflush(stdout);
    now=read();
    return now;
}

int main(){
    m=read();n=read();
    for(int i=1;i<=n;i++){
        l=query(1);
        if(!l){
            writeln(1);
            return 0;
        }else{
            if(l==1){
                use[i]=false;
            }else{
                use[i]=true;
            }
        }
    }
    l=1;r=m+1;
    while(l+1<r){
        int mid=(l+r)>>1;
        sum=sum%n+1;
        now=query(mid);
        if(!use[sum])now=-now;
        if(!now){
            writeln(mid);
            return 0;
        }else{
            if(now==1){
                r=mid;
            }else{
                l=mid;
            }
        }
    }
    if(!query(l)){
        writeln(l);
        return 0;
    }
    if(!query(r)){
        writeln(r);
        return 0;
    }
    return 0;
}


#include <iostream>
#include <cstdio>

using namespace std;

inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
    int x=0;char ch=gc();bool positive=1;
    for(;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
    for(;isdigit(ch);ch=gc())x=x*10+ch-'0';
    return positive?x:-x;
}

inline void write(int x){
    if(x<0)x=-x,putchar('-');
    if(x>9)write(x/10);putchar(x%10+'0');
}

inline void writeln(int x){
    write(x);puts("");
}

int n,m,sum,now,l,r,mid;
bool use[50];

inline int query(int x){
    int now;
    writeln(x);
    fflush(stdout);
    now=read();
    return now;
}

int main(){
    n=read();m=read();
    for(int i=1;i<=n;i++){
        l=query(1);
        if(!l){
            writeln(1);
            return 0;
        }else{
            if(l==1){
                use[i]=true;
            }else{
                use[i]=false;
            }
        }
    }
    l=1;r=m+1;
    while(l+1<r){
        int mid=(l+r)>>1;
        sum++;
        now=query(mid);
        if(!use[sum])now=-now;
        if(!now){
            writeln(mid);
            return 0;
        }else{
            if(now==1){
                l=mid;
            }else{
                r=mid;
            }
        }
    }
    if(!query(l)){
        writeln(l);
        return 0;
    }
    if(!query(r)){
        writeln(r);
        return 0;
    }
    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 310000
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int m,n;
    cin>>m>>n;
    int a[100]={};
    rep(i,n){
        printf("%d",i+1);
        fflush(stdout);
        int s;scanf("%d",&s);
        if(s==0) return 0;
        if(s==1) a[i]=1;
        else a[i]=0;
    }
    int l=n,r=m;
    while(1){
        rep(i,n){
            printf("%d",(l+r)/2);
            fflush(stdout);
            int s;scanf("%d",&s);
            if(s==0) return 0;
            if(a[i]==-1) s*=-1;
            if(s==1){
                l=(l+r)/2+1;
            }
            else r=(l+r)/2;
        }
    }
    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 310000
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int m,n;
    cin>>m>>n;
    int a[100]={};
    rep(i,n){
        cout<<i+1<<endl;
        fflush(stdout);
        int s;cin>>s;
        if(s==0) return 0;
        if(s==1) a[i]=1;
        else a[i]=0;
    }
    int l=n,r=m;
    while(1){
        rep(i,n){
            cout<<(l+r)/2<<endl;
            fflush(stdout);
            int s;cin>>s;
            if(s==0) return 0;
            if(a[i]==-1) s*=-1;
            if(s==1){
                l=(l+r)/2+1;
            }
            else r=(l+r)/2;
        }
    }
    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 310000
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int m,n;
    cin>>m>>n;
    int a[100]={};
    rep(i,n){
        printf("%d\n",i+1);
        fflush(stdout);
        int s;scanf("%d",&s);
        if(s==0) return 0;
        if(s==1) a[i]=1;
        else a[i]=0;
    }
    int l=n,r=m;
    while(1){
        rep(i,n){
            printf("%d\n",(l+r)/2);
            fflush(stdout);
            int s;scanf("%d",&s);
            if(s==0) return 0;
            if(a[i]==-1) s*=-1;
            if(s==1){
                l=(l+r)/2+1;
            }
            else r=(l+r)/2;
        }
    }
    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 310000
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int m,n;
    cin>>m>>n;
    int a[100]={};
    rep(i,n){
        printf("%d\n",i+1);
        fflush(stdout);
        int s;scanf("%d",&s);
        if(s==0) return 0;
        if(s==1) a[i]=1;
        else a[i]=-1;
    }
    int l=n,r=m;
    while(1){
        rep(i,n){
            printf("%d\n",(l+r)/2);
            fflush(stdout);
            int s;scanf("%d",&s);
            if(s==0) return 0;
            if(a[i]==-1) s*=-1;
            if(s==1){
                l=(l+r)/2+1;
            }
            else r=(l+r)/2;
        }
    }
    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 310000
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int m,n;
    cin>>m>>n;
    int a[100]={};
    rep(i,n){
        cout<<i+1;
        fflush(stdout);
        int s;cin>>s;
        if(s==0) return 0;
        if(s==1) a[i]=1;
        else a[i]=0;
    }
    int l=n,r=m;
    while(1){
        rep(i,n){
            cout<<(l+r)/2;
            fflush(stdout);
            int s;cin>>s;
            if(s==0) return 0;
            if(a[i]==-1) s*=-1;
            if(s==1){
                l=(l+r)/2+1;
            }
            else r=(l+r)/2;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,n) for(int (i)=0;(i)<(n);(i)++)
#define F first
#define S second
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define fill(x,a) fill((x).begin(),(x).end(),(a))
#define setbitcount __builtin_popcount
#define isodd __builtin_parity
#define clz __builtin_clz
#define ctz __builtin_ctz
#define pque priority_queue
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpi vector<pi>
#define vvpi vector<vector<pi>>
#define vpll vector<pll>
#define vvpll vector<vector<pll>>
#define pb push_back
#define mp make_pair
#define pln cout<<"\n";
#define endl "\n"
#define OPTIMISED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
typedef  long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
const ll inf9=1e9,inf18=1e18,inf6=1e6,inf14=1e14;
const ll mod7=inf9+7,mod9=inf9+9;
const int modi=998244353;
clock_t time_p=clock();
void clk()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int m,n;
vi seq;
int main()
{
	OPTIMISED
	int q=0;
	cin>>m>>n;
	forn(i,n)
	{
		cout<<"1"<<endl;
		cout.flush();
		q++;
		int x;cin>>x;
		if(x==0)
		{
			return 0;
		}
		if(x==-1)
		seq.pb(0);
		else seq.pb(1);
	}
	ll l=1,r=m;
	int num=0;
	while(true)
	{
		ll mid=(l+r)/2;
		cout<<mid<<endl;
		cout.flush();
		q++;
		int x;cin>>x;
		if(seq[num]==0)x=-x;
		if(x==-1)
		{
			r=mid;
		}
		if(x==1)
		{
			l=mid;
			if(l+1==r)
			l=r;
		}
		if(x==0)
		{
			return 0;
		}
		num++;num%=n;
		assert(q<=60);
	}
	clk();
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,n) for(int (i)=0;(i)<(n);(i)++)
#define F first
#define S second
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define fill(x,a) fill((x).begin(),(x).end(),(a))
#define setbitcount __builtin_popcount
#define isodd __builtin_parity
#define clz __builtin_clz
#define ctz __builtin_ctz
#define pque priority_queue
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpi vector<pi>
#define vvpi vector<vector<pi>>
#define vpll vector<pll>
#define vvpll vector<vector<pll>>
#define pb push_back
#define mp make_pair
#define pln cout<<"\n";
#define endl "\n"
#define OPTIMISED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
typedef  long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
const ll inf9=1e9,inf18=1e18,inf6=1e6,inf14=1e14;
const ll mod7=inf9+7,mod9=inf9+9;
const int modi=998244353;
clock_t time_p=clock();
void clk()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int m,n;
vi seq;
int main()
{
	OPTIMISED
	int q=0;
	cin>>m>>n;
	forn(i,n)
	{
		cout<<"1"<<endl;
		cout.flush();
		q++;
		int x;cin>>x;
		if(x==0)
		{
			return 0;
		}
		if(x==-1)
		seq.pb(0);
		else seq.pb(1);
	}
	int l=1,r=m;
	int num=0;
	while(true)
	{
		int mid=(l+r)/2;
		cout<<mid<<endl;
		cout.flush();
		q++;
		int x;cin>>x;
		if(seq[num]==0)x=-x;
		if(x==-1)
		{
			r=mid;
		}
		if(x==1)
		{
			l=mid;
			if(l+1==r)
			l=r;
		}
		if(x==0)
		{
			return 0;
		}
		num++;num%=n;
		assert(q<=60);
	}
	clk();
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,n) for(int (i)=0;(i)<(n);(i)++)
#define F first
#define S second
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define fill(x,a) fill((x).begin(),(x).end(),(a))
#define setbitcount __builtin_popcount
#define isodd __builtin_parity
#define clz __builtin_clz
#define ctz __builtin_ctz
#define pque priority_queue
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpi vector<pi>
#define vvpi vector<vector<pi>>
#define vpll vector<pll>
#define vvpll vector<vector<pll>>
#define pb push_back
#define mp make_pair
#define pln cout<<"\n";
#define endl "\n"
#define OPTIMISED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
typedef  long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
const ll inf9=1e9,inf18=1e18,inf6=1e6,inf14=1e14;
const ll mod7=inf9+7,mod9=inf9+9;
const int modi=998244353;
clock_t time_p=clock();
void clk()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int m,n;
vi seq;
int main()
{
	OPTIMISED
	int q=0;
	cin>>m>>n;
	forn(i,n)
	{
		cout<<"1"<<endl;
		cout.flush();
		q++;
		int x;cin>>x;
		if(x==0)
		{
			return 0;
		}
		if(x==-1)
		seq.pb(0);
		else seq.pb(1);
	}
	ll l=1,r=m;
	int num=0;
	while(true)
	{
		ll mid=(l+r)/2;
		cout<<mid<<endl;
		cout.flush();
		q++;
		int x;cin>>x;
		if(seq[num]==0)x=-x;
		if(x==-1)
		{
			r=mid;
		}
		if(x==1)
		{
			if(l+1==r)
			l=r;
			else
			l=mid;
		}
		if(x==0)
		{
			return 0;
		}
		num++;num%=n;
		assert(q<=60);
	}
	clk();
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,n) for(int (i)=0;(i)<(n);(i)++)
#define F first
#define S second
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define fill(x,a) fill((x).begin(),(x).end(),(a))
#define setbitcount __builtin_popcount
#define isodd __builtin_parity
#define clz __builtin_clz
#define ctz __builtin_ctz
#define pque priority_queue
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpi vector<pi>
#define vvpi vector<vector<pi>>
#define vpll vector<pll>
#define vvpll vector<vector<pll>>
#define pb push_back
#define mp make_pair
#define pln cout<<"\n";
#define endl "\n"
#define OPTIMISED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
typedef  long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
const ll inf9=1e9,inf18=1e18,inf6=1e6,inf14=1e14;
const ll mod7=inf9+7,mod9=inf9+9;
const int modi=998244353;
clock_t time_p=clock();
void clk()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int m,n;
vi seq;
int main()
{
	OPTIMISED
	int q=0;
	cin>>m>>n;
	forn(i,n)
	{
		cout<<"1"<<endl;
		cout.flush();
		q++;
		int x;cin>>x;
		if(x==0)
		{
			return 0;
		}
		if(x==-1)
		seq.pb(0);
		else seq.pb(1);
	}
	ll l=1,r=m;
	int num=0;
	while(true)
	{
		ll mid=(l+r)/2;
		cout<<mid<<endl;
		cout.flush();
		q++;
		int x;cin>>x;
		if(seq[num]==0)x=-x;
		if(x==-1)
		{
			r=mid-1;
		}
		if(x==1)
		{
			if(l+1==r)
			l=r;
			else
			l=mid+1;
		}
		if(x==0)
		{
			return 0;
		}
		num++;num%=n;
		assert(q<=60);
	}
	clk();
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,n) for(int (i)=0;(i)<(n);(i)++)
#define F first
#define S second
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define fill(x,a) fill((x).begin(),(x).end(),(a))
#define setbitcount __builtin_popcount
#define isodd __builtin_parity
#define clz __builtin_clz
#define ctz __builtin_ctz
#define pque priority_queue
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpi vector<pi>
#define vvpi vector<vector<pi>>
#define vpll vector<pll>
#define vvpll vector<vector<pll>>
#define pb push_back
#define mp make_pair
#define pln cout<<"\n";
#define endl "\n"
#define OPTIMISED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
typedef  long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
const ll inf9=1e9,inf18=1e18,inf6=1e6,inf14=1e14;
const ll mod7=inf9+7,mod9=inf9+9;
const int modi=998244353;
clock_t time_p=clock();
void clk()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int m,n;
vi seq;
int main()
{
	OPTIMISED
	cin>>m>>n;
	forn(i,n)
	{
		cout<<"1"<<endl;
		cout.flush();
		int x;cin>>x;
		if(x==0)
		{
			return 0;
		}
		if(x==-1)
		seq.pb(0);
		else seq.pb(1);
	}
	int l=1,r=m;
	int num=0;
	while(true)
	{
		int mid=(l+r)/2;
		cout<<mid<<endl;
		cout.flush();
		int x;cin>>x;
		if(seq[num]==0)x=-x;
		if(x==-1)
		{
			r=mid;
		}
		if(x==1)
		{
			l=mid;
			if(l+1==r)
			l=r;
		}
		if(x==0)
		{
			return 0;
		}
		num++;num%=n;
	}
	clk();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
#define db(x) cerr << #x << " = " << x << endl
#define _ << ", " <<
typedef long long ll;
const int N = 35;
int ok[N];

int main(){
  int m, n;
  cin >> m >> n;

  for(int i = 0; i < n; i++){
    int x;

    cout << m << endl;
    cin >> x;

    if(x == -2) return 0;
    if(x == 0) return 0;
    ok[i] = x;
  }

  int i = 1, j = 1e9;
  for(int k = 0;; k = (k + 1)%n){
    int mid = (i + j)/2;
    int x;

    cout << mid << endl;
    cin >> x;
    x *= ok[k];

    if(x == -2 or x == 2) return 0;
    if(x == 0) return 0;
    if(x == 1) j = mid - 1;
    else i = mid + 1;
  }
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
#define db(x) cerr << #x << " = " << x << endl
#define _ << ", " <<
typedef long long ll;
const int N = 35;
int ok[N];

int main(){
  int m, n;
  cin >> m >> n;

  for(int i = 0; i < n; i++){
    int x;

    cout << 1 << endl;
    cin >> x;

    if(x == 0 or x == -2 or x == 2) return 0;
    ok[i] = x;
  }

  int i = 2, j = m;
  for(int k = 0;; k = (k + 1)%n){
    int mid = (i + j)/2;
    int x;

    cout << mid << endl;
    cin >> x;
    x *= ok[k];

    if(x == 0 or x == -2 or x == 2) return 0;

    if(x == -1) j = mid - 1;
    else i = mid + 1;
  }
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
#define db(x) cerr << #x << " = " << x << endl
#define _ << ", " <<
typedef long long ll;
const int N = 35;
int ok[N];

int main(){
  int m, n;
  cin >> m >> n;

  for(int i = 0; i < n; i++){
    int x;

    cout << m << endl;
    cin >> x;

    if(x == 0 or x == -2 or x == 2) return 0;

    ok[i] = -x;
  }

  int i = 1, j = 1e9;
  for(int k = 0;; k = (k + 1)%n){
    int mid = (i + j)/2;
    int x;

    cout << mid << endl;
    cin >> x;
    x *= ok[k];

    if(x == 0 or x == -2 or x == 2) return 0;

    if(x == -1) j = mid - 1;
    else i = mid + 1;
  }
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
#define db(x) cerr << #x << " = " << x << endl
#define _ << ", " <<
typedef long long ll;
const int N = 35;
int ok[N];

int main(){
  int m, n;
  cin >> m >> n;

  for(int i = 0; i < n; i++){
    int x;

    cout << m << endl;
    fflush(stdout);
    cin >> x;

    if(x == 0 or x == -2 or x == 2) return 0;

    ok[i] = -x;
  }

  int i = 1, j = 1e9;
  for(int k = 0;; k = (k + 1)%n){
    int mid = (i + j)/2;
    int x;

    cout << mid << endl;
    fflush(stdout);
    cin >> x;
    x *= ok[k];

    if(x == 0 or x == -2 or x == 2) return 0;

    if(x == -1) j = mid - 1;
    else i = mid + 1;
  }
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
#define db(x) cerr << #x << " = " << x << endl
#define _ << ", " <<
typedef long long ll;
const int N = 35;
int ok[N];

int main(){
  int m, n;
  cin >> m >> n;

  for(int i = 0; i < n; i++){
    int x;

    cout << m << endl;
    cin >> x;

    if(x == 0) return 0;
    ok[i] = x;
  }

  int i = 1, j = 1e9;
  for(int k = 0;; k = (k + 1)%n){
    int mid = (i + j)/2;
    int x;

    cout << mid << endl;
    cin >> x;
    x *= ok[k];

    if(x == 0) return 0;
    if(x == 1) j = mid - 1;
    else i = mid + 1;
  }
}


#include <cstdio>
#include <climits>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

const int MAXN = 35;

int p[MAXN];

int main() {
    int m, n;
    scanf("%d %d", &m, &n);

    int hm = (m + 1) >> 1;
    for (int i = 0; i < n; i++) {
        printf("%d\n", hm);
        fflush(stdout);
        scanf("%d", &p[i]);
        if (p[i] == 0) return 0;
    }

    int i = 0, l, r;
    if (p[i] == 1) {
        l = hm + 1;
        r = m;
    } else {
        l = 1;
        r = hm - 1;
    }
    while (l <= r) {
        int mid = (l + r) >> 1;
        printf("%d\n", mid);
        fflush(stdout);
        int x;
        scanf("%d", &x);
        if (p[i] != p[0]) x = -x;
        if (!x) return 0;
        if (x == 1) {
            l = mid + 1;
        } else {
            r = mid - 1;
        }
        ++i;
    }

    if (p[0] == 1) {
        l = 1;
        r = hm - 1;
    } else {
        l = hm + 1;
        r = m;
    }
    while (l <= r) {
        int mid = (l + r) >> 1;
        printf("%d\n", mid);
        int x;
        scanf("%d", &x);
        if (p[i] == p[0]) x = -x;
        if (!x) return 0;
        if (x == 1) {
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }

    return 0;
}


#include <cstdio>

const int MAXN = 35;

int p[MAXN];

int main() {
    int m, n;
    scanf("%d %d", &m, &n);

    for (int i = 0; i < n; i++) {
        puts("1");
        fflush(stdout);
        scanf("%d", &p[i]);
        if (p[i] == 0 || p[i] == -2) return 0;
        p[i] = (p[i] == 1 ? 0 : 1);
    }

    int clock = 0, l = 2, r = m;
    while (l <= r) {
        int mid = l + ((r - l) >> 1);
        printf("%d\n", mid);
        fflush(stdout);

        int x;
        scanf("%d", &x);

        if (x == 0 || x == -2) return 0;

        if (p[clock]) x = -x;
        if (x == 1) {
            l = mid + 1;
        } else {
            r = mid - 1;
        }

        ++clock;
    }

    return 0;
}


#include <cstdio>

const int MAXN = 35;

int p[MAXN];

int main() {
    int m, n;
    scanf("%d %d", &m, &n);

    for (int i = 0; i < n; i++) {
        puts("1");
        fflush(stdout);
        scanf("%d", &p[i]);
        if (p[i] == 0) return 0;
        p[i] = (p[i] == 1 ? 0 : 1);
    }

    int clock = 0, l = 1, r = m;
    while (l <= r) {
        int mid = (l + r) >> 1;
        printf("%d\n", mid);
        fflush(stdout);

        int x;
        scanf("%d", &x);

        if (p[clock]) x = -x;

        if (!x) return 0;
        if (x == 1) {
            l = mid + 1;
        } else {
            r = mid - 1;
        }

        ++clock;
    }

    return 0;
}


#include <cstdio>

const int MAXN = 35;

int p[MAXN];

int main() {
    int m, n;
    scanf("%d %d", &m, &n);

    for (int i = 0; i < n; i++) {
        puts("1");
        fflush(stdout);
        scanf("%d", &p[i]);
        if (p[i] == 0 || p[i] == -2) return 0;
        p[i] = (p[i] == 1 ? 0 : 1);
    }

    int clock = 0, l = 2, r = m;
    while (l <= r) {
        int mid = l + ((r - l) >> 1);
        printf("%d\n", mid);
        fflush(stdout);

        int x;
        scanf("%d", &x);

        if (x == 0 || x == -2) return 0;

        if (p[clock % n]) x = -x;
        if (x == 1) {
            l = mid + 1;
        } else {
            r = mid - 1;
        }

        ++clock;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    int m,n;
    cin >> m >> n;
    for(int i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(x==0||x==-2)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    int l=2,r=m;
    int cnt=1;
    while(l<r)
    {
        int mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(x==0||x==-2)
            exit(0);
        if(p[cnt%n]==1)
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid;
        }
        else
        {
            if(x==1)
                r=mid;
            else if(x==-1)
                l=mid+1;
        }
        cnt++;
    }
    cout << l << "\n";
    fflush(stdout);
    exit(0);
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    int m,n;
    cin >> m >> n;
    for(int i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(x==0)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    int l=2,r=m;
    int cnt=1;
    while(l<r)
    {
        int mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(p[cnt%n]==1)
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid;
            else
                exit(0);
        }
        else
        {
            if(x==1)
                r=mid;
            else if(x==-1)
                l=mid+1;
            else
                exit(0);
        }
        cnt++;
    }
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    int m,n;
    cin >> m >> n;
    for(int i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(x==0||x==-2)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    int l=2,r=m;
    int cnt=1;
    while(l<r)
    {
        int mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(p[cnt%n]==1)
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid;
            else
                exit(0);
        }
        else
        {
            if(x==1)
                r=mid;
            else if(x==-1)
                l=mid+1;
            else
                exit(0);
        }
        cnt++;
    }
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    long long m,n;
    cin >> m >> n;
    for(long long i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    long long l=2,r=m;
    long long cnt=1;
    while(l!=r)
    {
        long long mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
            exit(0);
        if(p[cnt%n]==1)
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid-1;
        }
        else
        {
            if(x==1)
                r=mid-1;
            else if(x==-1)
                l=mid+1;
        }
        cnt++;
    }
    cout << l << "\n";
    fflush(stdout);
    exit(0);
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    long long m,n;
    cin >> m >> n;
    for(long long i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    long long l=2,r=m;
    long long cnt=1;
    while(l<r)
    {
        long long mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
            exit(0);
        if(p[cnt%n]==1)
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid;
        }
        else
        {
            if(x==1)
                r=mid;
            else if(x==-1)
                l=mid+1;
        }
        cnt++;
    }
    cout << l << "\n";
    fflush(stdout);
    exit(0);
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    long long m,n;
    cin >> m >> n;
    for(long long i=0;i<n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    long long l=2,r=m;
    long long cnt=0;
    while(l<r)
    {
        long long mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
            exit(0);
        if(p[cnt%n]==1)
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid-1;
        }
        else
        {
            if(x==1)
                r=mid-1;
            else if(x==-1)
                l=mid+1;
        }
        cnt++;
    }
    cout << l << "\n";
    fflush(stdout);
    exit(0);
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    int m,n;
    cin >> m >> n;
    for(int i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(x==0)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    int l=2,r=m;
    int cnt=1;
    while(l<r)
    {
        int mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(p[cnt%n]==1)
        {
            if(x==1)
                r=mid;
            else if(x==-1)
                l=mid+1;
            else
                exit(0);
        }
        else
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid;
            else
                exit(0);
        }
        cnt++;
    }
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    int m,n;
    cin >> m >> n;
    for(int i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(x==0)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    int l=2,r=m;
    int cnt=1;
    while(l<r)
    {
        int mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(p[cnt%n]==1)
        {
            if(x==1)
                r=mid-1;
            else if(x==-1)
                l=mid+1;
            else
                exit(0);
        }
        else
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid-1;
            else
                exit(0);
        }
        cnt++;
    }
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    int m,n;
    cin >> m >> n;
    for(int i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(x==0||x==-2)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    int l=2,r=m;
    int cnt=1;
    while(l<r)
    {
        int mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(p[cnt%n]==1)
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid-1;
            else
                exit(0);
        }
        else
        {
            if(x==1)
                r=mid-1;
            else if(x==-1)
                l=mid+1;
            else
                exit(0);
        }
        cnt++;
    }
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    long long m,n;
    cin >> m >> n;
    for(long long i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    long long l=2,r=m;
    long long cnt=1;
    while(l<r)
    {
        long long mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
            exit(0);
        if(p[cnt%n]==1)
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid-1;
        }
        else
        {
            if(x==1)
                r=mid-1;
            else if(x==-1)
                l=mid+1;
        }
        cnt++;
    }
    cout << l << "\n";
    fflush(stdout);
    exit(0);
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    int m,n;
    cin >> m >> n;
    for(int i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(x==0)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    int l=2,r=m;
    int cnt=1;
    while(l<r)
    {
        int mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(p[cnt%n]==1)
        {
            if(x==1)
                r=mid;
            else if(x==-1)
                l=mid+1;
            else
                exit(0);
        }
        else
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid-1;
            else
                exit(0);
        }
        cnt++;
    }
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    int m,n;
    cin >> m >> n;
    for(int i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(x==0)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    int l=2,r=m;
    int cnt=1;
    while(l<r)
    {
        int mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        int x;
        cin >> x;
        if(p[cnt%n]==1)
        {
            if(x==1)
                r=mid;
            else if(x==-1)
                l=mid+1;
            else
                exit(0);
        }
        else
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid;
            else
                exit(0);
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    long long m,n;
    cin >> m >> n;
    for(long long i=1;i<=min(n,m);i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    long long l=2,r=m;
    long long cnt=1;
    while(l<r)
    {
        long long mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
            exit(0);
        if(p[cnt%n]==1)
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid;
        }
        else
        {
            if(x==1)
                r=mid;
            else if(x==-1)
                l=mid+1;
        }
        cnt++;
    }
    cout << l << "\n";
    fflush(stdout);
    exit(0);
}


#include <bits/stdc++.h>
using namespace std;
bool p[80];
int main()
{
    long long m,n;
    cin >> m >> n;
    for(long long i=1;i<=n;i++)
    {
        cout << "1" << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
        {
            exit(0);
        }
        if(x==1)
        {
            p[i]=1;
        }
        else
        {
            p[i]=0;
        }
    }
    long long l=1,r=m;
    long long cnt=1;
    while(l<r)
    {
        long long mid=(l+r)/2;
        cout << mid << "\n";
        fflush(stdout);
        long long x;
        cin >> x;
        if(x==0||x==-2)
            exit(0);
        if(p[cnt%n]==1)
        {
            if(x==1)
                l=mid+1;
            else if(x==-1)
                r=mid;
        }
        else
        {
            if(x==1)
                r=mid;
            else if(x==-1)
                l=mid+1;
        }
        cnt++;
    }
    cout << l << "\n";
    fflush(stdout);
    exit(0);
}


#include <iostream>
#include <iomanip>
using namespace std;
int a[300000] , cd , m ,  n ;

int main()
{
	cin >> m >> n;
	int cur = 1;
	for (int i = 1 ; i <= n ; i++)
	{
		int res;
		cout << 1<<'\n';
		fflush(stdout);
		cin >> res;
		if (res == 1)
		{
			a[i] = 1;
		}
		else
		{
			a[i] = 0;
		}
		cur = i;
	}
	int l = 1 , r = m;
	while (r >= l)
	{
		int mid = (l + r) / 2;
		cout <<mid<<'\n';
		fflush(stdout);
		int res;
		cur++;
		if (cur > n)
		{
			cur = 1;
		}
		if (res == 0)
		{
			exit(0);
		}
		if (a[cur] == 1)
		{
			if (res == 1)
			{
				l = mid + 1;
			}
			else
			{
				r = mid - 1;
			}
		}
		else
		{
			if (res == 1)
			{
				r = mid - 1;
			}
			else
			{
				l = mid + 1;
			}
		}
	}
}


#include <iostream>
#include <iomanip>
using namespace std;
int a[300000] , cd , m ,  n ;

int main()
{
	cin >> m >> n;
	int cur = 1;
	for (int i = 1 ; i <= n ; i++)
	{
		int res;
		cout << 1<<'\n';
		fflush(stdout);
		cin >> res;
		if (res == 0)
		{
		    exit(0);
		}
		if (res == 1)
		{
			a[i] = 1;
		}
		else
		{
			a[i] = 0;
		}
		cur = i;
	}
	int l = 1 , r = m;
	while (r >= l)
	{
		int mid = (l + r) / 2;
		cout <<mid<<'\n';
		fflush(stdout);
		int res;
		cur++;
		if (cur > n)
		{
			cur = 1;
		}
		if (res == 0)
		{
			exit(0);
		}
		if (a[cur] == 1)
		{
			if (res == 1)
			{
				l = mid + 1;
			}
			else
			{
				r = mid - 1;
			}
		}
		else
		{
			if (res == 1)
			{
				r = mid - 1;
			}
			else
			{
				l = mid + 1;
			}
		}
	}
}


#include <iostream>
#include <iomanip>
using namespace std;
int a[300000] , cd , m ,  n ;

int main()
{
	cin >> m >> n;
	int cur = 1;
	for (int i = 1 ; i <= n ; i++)
	{
		int res;
		cout << 1<<'\n';
		fflush(stdout);
		cin >> res;
		if (res == 1)
		{
			a[i] = 1;
		}
		else
		{
			a[1] = 0;
		}
		cur = i;
	}
	int l = 1 , r = m;
	while (r >= l)
	{
		int mid = (l + r) / 2;
		cout <<mid<<'\n';
		fflush(stdout);
		int res;
		cur++;
		if (cur > n)
		{
			cur = 1;
		}
		if (res == 0)
		{
			exit(0);
		}
		if (a[cur] == 1)
		{
			if (res == 1)
			{
				l = mid + 1;
			}
			else
			{
				r = mid - 1;
			}
		}
		else
		{
			if (res == 1)
			{
				r = mid - 1;
			}
			else
			{
				l = mid + 1;
			}
		}
	}
}


#include <iostream>
#include <iomanip>
using namespace std;
int a[300000] , cd , m ,  n ;

int main()
{
	cin >> m >> n;
	int cur ;
	for (int i = 1 ; i <= n ; i++)
	{
		int res;
		cout << 1<<'\n';
		fflush(stdout);
		cin >> res;
		if (res == 0)
		{
		    exit(0);
		}
		if (res == 1)
		{
			a[i] = 1;
		}
		else
		{
			a[i] = 0;
		}
		cur = i;
	}
	int l = 2 , r = m;
	while (r >= l)
	{
		int mid = (l + r) / 2;
		cout <<mid<<'\n';
		fflush(stdout);
		int res;
		cur++;
		if (cur > n)
		{
			cur = 1;
		}
		cin >> res;
		if (res == 0)
		{
			exit(0);
		}
		if (a[cur] == 1)
		{
			if (res == 1)
			{
				l = mid + 1;
			}
			else
			{
				r = mid - 1;
			}
		}
		else
		{
			if (res == 1)
			{
				r = mid - 1;
			}
			else
			{
				l = mid + 1;
			}
		}
	}
}


#include <iostream>
#include <iomanip>
using namespace std;
int a[300000] , cd , m ,  n ;

int main()
{
	cin >> m >> n;
	for (int i = 1 ; i <= n ; i++)
	{
		int res;
		cout << 1<<'\n';
		fflush(stdout);
		cin >> res;
		if (res == 0)
		{
		    exit(0);
		}
		if (res == 1)
		{
			a[i] = 1;
		}
		else
		{
			a[i] = 0;
		}
		cur = i;
	}
	int l = 2 , r = m;
	while (r >= l)
	{
		int mid = (l + r) / 2;
		cout <<mid<<'\n';
		fflush(stdout);
		int res;
		cur++;
		if (cur > n)
		{
			cur = 1;
		}
		cin >> res;
		if (res == 0)
		{
			exit(0);
		}
		if (a[cur] == 1)
		{
			if (res == 1)
			{
				l = mid + 1;
			}
			else
			{
				r = mid - 1;
			}
		}
		else
		{
			if (res == 1)
			{
				r = mid - 1;
			}
			else
			{
				l = mid + 1;
			}
		}
	}
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
int p[10001];
void ask(int x)
{
	printf("%d\n",x);
	fflush(stdout);
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		ask(1);
		scanf("%d",&p[i]);
		if(p[i]==0)
		{
			printf("1");
			return 0;
		}
	}
	int l=0,r=m;
	for(int i=1;i<=30;i++)
	{
		int mid=(l+r)/2,t;
		ask(mid);
		scanf("%d",&t);
		if(t*p[i%n+1]==0)
		{
			printf("%d",mid);
			return 0;
		}
		if(t*p[i%n+1]<0)
			r=mid;
		else
			l=mid;
	}
	return 0;
}
/*
1 5
3

1
*/


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
int p[10001];
void ask(int x)
{
	printf("%d\n",x);
	fflush(stdout);
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		ask(1);
		scanf("%d",&p[i]);
		if(p[i]==0)
		{
			printf("1");
			return 0;
		}
	}
	int l=0,r=1e9+1;
	for(int i=1;i<=30;i++)
	{
		int mid=(l+r)/2,t;
		ask(mid);
		scanf("%d",&t);
		if(t*p[i]==0)
		{
			printf("%d",mid);
			return 0;
		}
		if(t*p[i]<0)
			r=mid;
		else
			l=mid;
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
int p[10001];
void ask(int x)
{
	printf("%d\n",x);
	fflush(stdout);
}
int main()
{
	int n,m;
	scanf("%d%d",&m,&n);
	for(int i=1;i<=n;i++)
	{
		ask(1);
		scanf("%d",&p[i]);
		if(p[i]==0)
		{
			printf("1");
			return 0;
		}
	}
	int l=1,r=m;
	for(int i=1;i<=30;i++)
	{
		int mid=(l+r)/2,t;
		ask(mid);
		scanf("%d",&t);
		if(t*p[i%n+1]==0)
		{
			printf("%d",mid);
			return 0;
		}
		if(t*p[i%n+1]<0)
			r=mid;
		else
			l=mid;
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
int p[10001];
void ask(int x)
{
	printf("%d\n",x);
	fflush(stdout);
}
int main()
{
	int n,m;
	scanf("%d%d",&m,&n);
	for(int i=1;i<=n;i++)
	{
		ask(1);
		scanf("%d",&p[i]);
		if(p[i]==0)
		{
			printf("1");
			return 0;
		}
	}
	int l=1,r=m;
	for(int i=1;i<=30;i++)
	{
		int mid=(l+r)/2,t;
		ask(mid);
		scanf("%d",&t);
		if(t*p[(i-1)%n+1]==0)
		{
			printf("%d",mid);
			return 0;
		}
		if(t*p[(i-1)%n+1]<0)
			r=mid-1;
		else
			l=mid+1;
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
int p[10001];
void ask(int x)
{
	printf("%d\n",x);
	fflush(stdout);
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		ask(1);
		scanf("%d",&p[i]);
		if(p[i]==0)
		{
		//	printf("1");
			return 0;
		}
	}
	int l=0,r=m;
	for(int i=1;i<=30;i++)
	{
		int mid=(l+r)/2,t;
		ask(mid);
		scanf("%d",&t);
		if(t*p[i%n+1]==0)
		{
		//	printf("%d",mid);
			return 0;
		}
		if(t*p[i%n+1]<0)
			r=mid;
		else
			l=mid;
	}
	return 0;
}
/*
1 5
3

1
*/


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
int p[10001];
void ask(int x)
{
	printf("%d\n",x);
	fflush(stdout);
}
int main()
{
	int n,m;
	scanf("%d%d",&m,&n);
	for(int i=1;i<=n;i++)
	{
		ask(1);
		scanf("%d",&p[i]);
		if(p[i]==0)
		{
			printf("1");
			return 0;
		}
	}
	int l=0,r=m;
	for(int i=1;i<=30;i++)
	{
		int mid=(l+r)/2,t;
		ask(mid);
		scanf("%d",&t);
		if(t*p[i%n+1]==0)
		{
			printf("%d",mid);
			return 0;
		}
		if(t*p[i%n+1]<0)
			r=mid;
		else
			l=mid;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
clock_t __t=clock();
#define rep(i,x,y) for (int i=(x);i<=(y);++i)
#define drep(i,y,x) for (int i=(y);i>=(x);--i)
#define temp template<typename T>
temp bool chkmin(T &x,T y){return x>y?x=y,1:0;}
temp bool chkmax(T &x,T y){return x<y?x=y,1:0;}
#define ll long long
#define db double
void file()
{
	#ifdef NTFAKIOI
	freopen("a.in","r",stdin);
	#endif
}
void chktime()
{
	#ifdef NTFAKIOI
	cout<<1.0*(clock()-__t)/1000;
	#endif
}
temp void read(T &x)
{
	x=0;char ch=getchar(),t=0;
	while (ch>'9'||ch<'0') t|=(ch=='-'),ch=getchar();
	while (ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
	x=(t?-x:x);
}
#define go(x) for (int i=head[x];i;i=edge[i].nxt)
#define pii pair<int,int>
#define fir first
#define sec second
#define MP make_pair

ll m;
int n;
bool type[35];

int ask(int x){printf("%d\n",x);fflush(stdout);int ret;read(ret);if (ret==-2||!ret) exit(0);return ret;}

int main()
{
//	file();
	read(m),read(n);
	rep(i,1,n) type[i]=(ask(m)==-1);
	int l=1,r=m,i=1;
	while (l<=r)
	{
		int mid=(l+r)>>1,c=ask(mid);
		if (!c) return 0;
		if (!type[i]) c=-c;
		if (c>0) l=mid+1;
		else r=mid-1;
		++i;if (i>n) i-=n;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
clock_t __t=clock();
#define rep(i,x,y) for (int i=(x);i<=(y);++i)
#define drep(i,y,x) for (int i=(y);i>=(x);--i)
#define temp template<typename T>
temp bool chkmin(T &x,T y){return x>y?x=y,1:0;}
temp bool chkmax(T &x,T y){return x<y?x=y,1:0;}
#define ll long long
#define db double
void file()
{
	#ifdef NTFAKIOI
	freopen("a.in","r",stdin);
	#endif
}
void chktime()
{
	#ifdef NTFAKIOI
	cout<<1.0*(clock()-__t)/1000;
	#endif
}
temp void read(T &x)
{
	x=0;char ch=getchar(),t=0;
	while (ch>'9'||ch<'0') t|=(ch=='-'),ch=getchar();
	while (ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
	x=(t?-x:x);
}
#define go(x) for (int i=head[x];i;i=edge[i].nxt)
#define pii pair<int,int>
#define fir first
#define sec second
#define MP make_pair

ll m;
int n;
bool type[35];

int ask(int x){printf("%d\n",x);fflush(stdout);int ret;read(ret);if (ret==-2) exit(0);return ret;}

int main()
{
//	file();
	read(m),read(n);
	rep(i,1,n) type[i]=(ask(m+1)==-1);
	int l=1,r=m,i=1;
	while (l<=r)
	{
		int mid=(l+r)>>1,c=ask(mid);
		if (!c) return 0;
		if (!type[i]) c=-c;
		if (c>0) l=mid+1;
		else r=mid-1;
		++i;if (i>n) i-=n;
	}
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>

using namespace std;

#define mp make_pair
#define pb push_back
#define LL long long
#define ULL unsigned long long
#define BASE 73
#define NMAX 10000
#define NMAX2 20001
#define MOD1 1000000007
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define get_max(val1, val2) val1 = max(val1, val2);

int PASSED_POINT = 0;

void Duxar() {
#ifndef ONLINE_JUDGE
	printf("\n . . . . . . . . . . . . . Passed point - %d\n", ++PASSED_POINT);
#endif
}

template <class T>
void read_int(T &_value) {
	T sign = 1;
	char ch;
	_value = 0;
	while(!isdigit(ch = getchar())) {
		(ch == '-') && (sign = -1);
	}
	do {
		_value = _value * 10 + (ch - '0');
	} while(isdigit(ch = getchar()));
	_value *= sign;
}

template <class T>
T add_nr(T a, T b) {
	T _res = a + b;
	return _res % MOD1;
}

int N;
string original;
vector <string> updates;
vector <int> dp_digits(10, -1);
vector <LL> lengs(10, 1);

int ComputeReminder(string update, int pos = 3);
int Rise(int x, LL p);

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.cpp", "r", stdin);
#endif

	int i, ans = 0;

	cin >> original;
	cin >> N;
	updates.resize(N);
	for (i = 0; i < N; ++i) {
		cin >> updates[i];
	}

	for (i = N - 1; i >= 0; --i) {
		ComputeReminder(updates[i]);
	}

	ans = ComputeReminder(original, 0);
	printf("%d\n", ans);

	return 0;
}

int ComputeReminder(string update, int pos) {
	int dig = update[0] - '0', lg = update.length(), i, w;
	LL ans = 0, new_leng = 0, aux_leng;

	if (pos == 3 && lg == 3) {
		lengs[dig] = 0;
		dp_digits[dig] = 0;
		return 0;
	}
	for (i = pos; i < lg; ++i) {
		w = update[i] - '0';
		++new_leng;
		aux_leng = 1;
		if (dp_digits[w] != -1) {
			aux_leng = lengs[w];
			new_leng += lengs[w] - 1;
			w = dp_digits[w];
		}
		ans = (ans * Rise(10, aux_leng)) % MOD1 + w;

		if (ans >= MOD1) {
			ans %= MOD1;
		}
//		cout << ans << ' ';
	}
	dp_digits[dig] = ans % MOD1;
	lengs[dig] = new_leng % MOD1;
	return ans;
}

int Rise(int x, LL p) {
	if (p == 0) return 1;
	if (p == 1) return x;
	LL ans = Rise(x, p / 2);
	ans = (ans * ans) % MOD1;
	if (p & 1) {
		return (ans * x) % MOD1;
	}
	return ans;
}