#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    int ok=true;
    vector<int>v;
    int l=1;
    int r=m;
    int mid;
    for(int i=0; i<n; i++)
    {
        mid=(l+r)/2.0;
        mid = (l + r + 1) / 2;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0)
        {
            r = mid - 1;
            v.push_back(-1);
        }
        else if(strcmp(response, "1") == 0)
        {
            l = mid;
            v.push_back(1);
        }
        else
        {
            return 0;
        }
    }
    l=1;
    r=m;
    for(int i=0; i<n; i++)
    {
        mid=(l+r)/2.0;
        mid = (l + r + 1) / 2;
        mid=m-mid;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "1") == 0)
        {
            if(v[i]==-1)
                r = mid - 1;
            else
            {
                l=mid;
            }
        }
        else if(strcmp(response, "-1") == 0)
        {
            if(v[i]==1)
                l = mid;
            else
            {
                r=mid-1;
            }
        }
        else
        {
            return 0;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    int ok=true;
    vector<int>v;
    int l=1;
    int r=m;
    int mid;
    for(int i=0; i<n; i++)
    {
        mid=1;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "1") == 0)
            {
                v.push_back(1);
            }
        else if(strcmp(response, "-1") == 0)
            {
                v.push_back(0);

            }
        else
        {
            return 0;
        }
    }
    l=1;
    r=m;
    while(l<=r)
    {
       // mid=(l+r)/2.0;
        mid = (l + r + 1) / 2;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0)
           { //r = mid - 1;
               if(v[i]==0){
                   l=mid+1;
               }
               else r=mid-1;

           }
        else if(strcmp(response, "1") == 0)
           { if(v[i]==0)
                r=mid-1;
           else l = mid+1;}
        else
        {
            return 0;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    int ok=true;
    vector<int>v;
    int l=1;
    int r=m;
    int mid;
    for(int i=0; i<n; i++)
    {
        mid=1;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0)
            {
                v.push_back(1);
            }
        else if(strcmp(response, "1") == 0)
            {
                v.push_back(0);

            }
        else
        {
            return 0;
        }
    }
    l=1;
    r=m;
    for(int i=0; i<n; i++)
    {
        mid=(l+r)/2.0;
        mid = (l + r + 1) / 2;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0)
           { //r = mid - 1;
               if(v[i]==0){
                   l=mid+1;
               }
               else r=mid-1;

           }
        else if(strcmp(response, "1") == 0)
           { if(v[i]==0)
                r=mid-1;
           else l = mid+1;}
        else
        {
            return 0;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    int ok=true;
    vector<int>v;
    int l=1;
    int r=m;
    int mid;
    for(int i=0; i<n; i++)
    {
        mid=(l+r)/2.0;
        mid = (l + r + 1) / 2;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0)
        {
            r = mid - 1;
            v.push_back(-1);
        }
        else if(strcmp(response, "1") == 0)
        {
            l = mid;
            v.push_back(1);
        }
        else
        {
            return 0;
        }
    }
    l=1;
    r=m;
    for(int i=0; i<n; i++)
    {
        mid=(l+r)/2.0;
        mid = (l + r + 1) / 2;
        mid=m-mid;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "1") == 0)
        {
            if(v[i]==-1) l=mid;

            else
            { r = mid - 1;

            }
        }
        else if(strcmp(response, "-1") == 0)
        {
            if(v[i]==1)
               r=mid-1;
            else
            { l = mid;

            }
        }
        else
        {
            return 0;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    int ok=true;
    vector<int>v;
    int l=1;
    int r=m;
    int mid;
    for(int i=0; i<n; i++)
    {
        mid=(l+r)/2.0;
        mid = (l + r + 1) / 2;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0)
        {
            r = mid - 1;
            v.push_back(-1);
        }
        else if(strcmp(response, "1") == 0)
        {
            l = mid;
            v.push_back(1);
        }
        else
        {
            return 0;
        }
    }
    int ans=mid;
    l=1;
    r=m;
    for(int i=0; i<n; i++)
    {
        mid=(l+r)/2.0;
        mid = (l + r + 1) / 2;
        mid=m-mid;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0){
            r = mid - 1;
        }
        else if(strcmp(response, "1") == 0)
            l = mid;
        else
        {
            return 0;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    int ok=true;
    vector<int>v;
    int l=1;
    int r=m;
    int mid;
    for(int i=0; i<n; i++)
    {
        mid=1;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0)
            {
                v.push_back(1);
            }
        else if(strcmp(response, "1") == 0)
            {
                v.push_back(0);

            }
        else
        {
            return 0;
        }
    }
    l=1;
    r=m;
    for(int i=0; i<n; i++)
    {
        mid=(l+r)/2.0;
        mid = (l + r + 1) / 2;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0)
           { //r = mid - 1;
               if(v[i]==0){
                   l=mid;
               }
               else r=mid-1;

           }
        else if(strcmp(response, "1") == 0)
           { if(v[i]==0)
                r=mid-1;
           else l = mid;}
        else
        {
            return 0;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    int ok=true;
    vector<int>v;
    int l=1;
    int r=m;
    int mid;
    for(int i=0; i<n; i++)
    {
        mid=1;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "1") == 0)
            {
                v.push_back(1);
            }
        else if(strcmp(response, "-1") == 0)
            {
                v.push_back(0);

            }
        else
        {
            return 0;
        }
    }
    l=1;
    r=m;
    for(int i=0; i<n; i++)
    {
        mid=(l+r)/2.0;
        mid = (l + r + 1) / 2;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0)
           { //r = mid - 1;
               if(v[i]==0){
                   l=mid+1;
               }
               else r=mid-1;

           }
        else if(strcmp(response, "1") == 0)
           { if(v[i]==0)
                r=mid-1;
           else l = mid+1;}
        else
        {
            return 0;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    int ok=true;
    vector<int>v;
    int l=1,l1=1;
    int r=m,r1=m;
    int mid=(l + r + 1) / 2,mid1=(l1 + r1 + 1) / 2;;
    for(int i=0; i<2*n; i++)
    {
        mid = (l + r + 1) / 2;
        mid1 = (l1 + r1 + 1) / 2;
        printf("%d\n", mid);
        fflush(stdout);
        char response[5];
        scanf("%s", response);
        if (strcmp(response, "-1") == 0)
        {
            r = mid - 1;
            v.push_back(-1);
        }
        else if(strcmp(response, "1") == 0)
        {
            l = mid;
            v.push_back(1);
        }
        else
        {
            return 0;
        }

        printf("%d\n", mid1);
        fflush(stdout);
        response[5];
        scanf("%s", response);
        if (strcmp(response, "1") == 0)
        {
            r1 = mid1 - 1;
            v.push_back(-1);
        }
        else if(strcmp(response, "-1") == 0)
        {
            l1 = mid1;
            v.push_back(1);
        }
        else
        {
            return 0;
        }
    }

}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<30;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      cout << 1 << '\n';
      return 0;
    }
    if (x[i]==1) x[i]=0;
    else x[i]=1;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      cout << t << '\n';
      return 0;
    }
    if (t>0) hi=mid;
    else lo=mid;
    curr++;
  }
  cout << hi << '\n';

  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<30;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      cout << 1 << '\n';
      return 0;
    }
    if (x[i]==1) x[i]=0;
    else x[i]=1;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      cout << t << '\n';
      return 0;
    }
    if (t>0) hi=mid;
    else lo=mid;
  }
  cout << hi << '\n';

  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <assert.h>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<n;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      cout << 1 << '\n';
      return 0;
    }
    if (x[i]!=1) x[i]=0;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      cout << t << '\n';
      return 0;
    }
    if (t>0) lo=mid+1;
    else hi=mid-1;
    curr++;
  }
  cout << hi << '\n';
  fflush(stdout);
  cin >> i;
  if (i!=0) {
    cout << lo << '\n';
  }
  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <assert.h>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<n;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      cout << 1 << '\n';
      return 0;
    }
    if (x[i]!=1) x[i]=0;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      cout << t << '\n';
      return 0;
    }
    if (t>0) lo=mid;
    else hi=mid-1;
    curr++;
  }
  cout << hi << '\n';
  fflush(stdout);
  cin >> i;
  if (i!=0) {
    cout << lo << '\n';
  }
  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <assert.h>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<n;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      cout << 1 << '\n';
      return 0;
    }
    if (x[i]!=1) x[i]=0;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      cout << t << '\n';
      return 0;
    }
    if (t>0) lo=mid+1;
    else hi=mid-1;
    curr++;
    if (curr>n) curr-=n;
  }
  cout << hi << '\n';
  fflush(stdout);
  cin >> i;

  if (i!=0) {
    cout << lo << '\n';
  }
  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<n;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      cout << 1 << '\n';
      return 0;
    }
    if (x[i]!=1) x[i]=0;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      cout << t << '\n';
      return 0;
    }
    if (t>0) lo=mid;
    else hi=mid-1;
    curr++;
  }
  cout << hi << '\n';

  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0;
  cin >> m >> n;
  for (i=0;i<30;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      cout << 1 << '\n';
      return 0;
    }
    if (x[i]==1) x[i]=0;
    else x[i]=1;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      cout << t << '\n';
      return 0;
    }
    if (t>0) hi=mid;
    else lo=mid;
  }
  cout << hi << '\n';

  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <assert.h>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<n;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      return 0;
    }
    if (x[i]!=1) x[i]=0;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      return 0;
    }
    if (t>0) lo=mid+1;
    else hi=mid-1;
    curr++;
    if (curr>=n) curr-=n;
  }
  cout << hi << '\n';
  fflush(stdout);
  cin >> i;

  if (i!=0) {
    cout << lo << '\n';
    fflush(stdout);
    cin >> i;
    assert(i==0);
  }
  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <assert.h>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<n;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      cout << 1 << '\n';
      return 0;
    }
    if (x[i]!=1) x[i]=0;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      cout << t << '\n';
      return 0;
    }
    if (t>0) lo=mid+1;
    else hi=mid-1;
    curr++;
    if (curr>n) curr-=n;
  }
  cout << hi << '\n';
  fflush(stdout);
  cin >> i;

  if (i!=0) {
    cout << lo << '\n';
    fflush(stdout);
    cin >> i;
  }
  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<30;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      cout << 1 << '\n';
      return 0;
    }
    if (x[i]!=1) x[i]=0;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      cout << t << '\n';
      return 0;
    }
    if (t>0) lo=mid;
    else hi=mid-1;
    curr++;
  }
  cout << hi << '\n';

  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <assert.h>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<n;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      return 0;
    }
    if (x[i]!=1) x[i]=0;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      return 0;
    }
    if (t>0) lo=mid+1;
    else hi=mid-1;
    curr++;
    if (curr>n) curr-=n;
  }
  cout << hi << '\n';
  fflush(stdout);
  cin >> i;

  if (i!=0) {
    cout << lo << '\n';
    fflush(stdout);
    cin >> i;
  }
  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <assert.h>
#include <vector>
#include <map>

#define N 200005
#define LL long long int
using namespace std;

int x[N];
int main() {
  int m,n,curr=0,i;
  cin >> m >> n;
  for (i=0;i<n;i++) {
    cout << 1 << '\n';
    fflush(stdout);
    cin >> x[i];
    if (x[i]==0) {
      cout << 1 << '\n';
      return 0;
    }
    if (x[i]!=1) x[i]=0;
  }
  int lo=1,mid,hi=m,t;
  while(lo<hi-1) {
    mid=(lo+hi)/2;
    cout << mid << '\n';
    fflush(stdout);
    cin >> t;
    if (x[curr]==0) t*=-1;
    if (t==0) {
      cout << t << '\n';
      return 0;
    }
    if (t>0) lo=mid;
    else hi=mid-1;
    curr++;
  }
  cout << hi << '\n';
  fflush(stdout);
  cin >> i;
  assert(i==0);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int p[62];
int m,n;
int main(){
// 	freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	int l = 1,r = m,id = 0;
	while(l <= r){
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> p[id++];
		if(!p[id - 1])return 0;
		if(p[id - 1] == 1)r = mid - 1;
		else l = mid + 1;
	}
	for(int i = 0;i + id <= n;i++)cout << 1 << endl;
	l = 0,r = m,id = 0;
	int x;
	while(l <= r){
		int mid = (l + r)/2;
		if(p[id] == 1){
			cout << r << endl;
			cin >> x;
			if(!x)return 0;
			if(x == 1){
				r = mid - 1;
				id++;
				continue;
			}
			l = mid + 1;
			id++;
			continue;
		}
		else{
			cout << l << endl;
			cin >> x;
			if(!x)return 0;
			if(x == -1){
				l = mid + 1;
				id++;
				continue;
			}
			r = mid - 1;
			id++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int p[62];
int m,n;
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	for(int i = 0;i < n;i++){
		cout << 1 << endl;
		cin >> p[i];
		if(!p[i])return 0;
	}
	int l = 1,r = m,id = -1;
	int x;
	while(l <= r){
		id++;
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> x;
		if(!x)return 0;
		if(p[id] == 1)x*=-1;
		if(x == 1)r = mid - 1;
		else l = mid + 1;
	}
}


#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int p[62];
int m,n;
int main(){
//	freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	int l = 1,r = m,id = 0;
	while(l <= r){
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> p[id++];
		if(!p[id - 1])return 0;
		if(p[id - 1] == 1)r = mid - 1;
		else l = mid + 1;
	}
	for(int i = 0;i + id < n;i++)cout << 1 << endl;
	int l = 0,r = m,id = 0,x;
	while(l <= r){
		int mid = (l + r)/2;
		if(p[id] == 1){
			cout << r << endl;
			cin >> x;
			if(!x)return 0;
			if(x == 1){
				r = mid - 1;
				id++;
				continue;
			}
			l = mid + 1;
			id++;
			continue;
		}
		else{
			cout << l << endl;
			cin >> x;
			if(!x)return 0;
			if(x == -1){
				l = mid + 1;
				id++;
				continue;
			}
			r = mid - 1;
			id++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int p[62];
int m,n;
int main(){
// 	freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	int l = 1,r = m,id = 0;
	for(int i = 0;i < n;i++){
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> p[id++];
		if(!p[id - 1])return 0;
		if(p[id - 1] == 1)r = mid;
		else l = mid;
	}
	l = 1,r = m,id = 0;
	int ol = 1,ori = 1;
	int x;
	while(l <= r){
		int mid = (l + r)/2;
		int omid = (ol + ori)/2;
		if(p[id] == 1){
			cout << r << endl;
			cin >> x;
			if(!x)return 0;
			if(x == 1 && (r > omid)){
				r = mid;
				id++;
				continue;
			}
			l = mid;
			id++;
			continue;
		}
		else{
			cout << l << endl;
			cin >> x;
			if(!x)return 0;
			if(x == -1 && (l < omid)){
				l = mid;
				id++;
				continue;
			}
			r = mid;
			id++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int p[62];
int m,n;
int main(){
// 	freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	for(int i = 0;i < n;i++){
		cout << mid << endl;
		cin >> p[i];
		if(!p[i])return 0;
		p[i] = p[i] == 1;
	}
	int l = 0,r = m,id = -1;
	int x;
	while(l <= r){
		id++;
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> x;
		if(!x)return 0;
		if(!p[id])x*=-1;
		if(x == 1)r = mid - 1;
		else l = mid + 1;
	}
}


#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int p[62];
int m,n;
int main(){
// 	freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	int l = 1,r = m,id = 0;
	for(int i = 0;i < n;i++){
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> p[id++];
		if(!p[id - 1])return 0;
		if(p[id - 1] == 1)r = mid;
		else l = mid;
	}
	l = 0,r = m,id = 0;
	bool same = 1;
	int x;
	while(l <= r){
		int mid = (l + r)/2;
		if(p[id] == 1){
			cout << r << endl;
			cin >> x;
			if(!x)return 0;
			if(x == 1 && same || !same && x == -1){
				r = mid;
				id++;
				same^=1;
				continue;
			}
			l = mid;
			id++;
			continue;
		}
		else{
			cout << l << endl;
			cin >> x;
			if(!x)return 0;
			if(x == -1 && same || !same && x == 1){
				l = mid;
				id++;
				same^=1;
				continue;
			}
			r = mid;
			id++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int p[62];
int m,n;
int main(){
// 	freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	for(int i = 0;i < n;i++){
		cout << 1 << endl;
		cin >> p[i];
		if(!p[i])return 0;
		p[i] = p[i] == 1;
	}
	int l = 0,r = m,id = -1;
	int x;
	while(l <= r){
		id++;
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> x;
		if(!x)return 0;
		if(!p[id])x*=-1;
		if(x == 1)r = mid - 1;
		else l = mid + 1;
	}
}


#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int p[62];
int m,n;
int main(){
//	freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	int l = 1,r = m,id = 0;
	for(int i = 0;i < n;i++){
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> p[id++];
		if(!p[id - 1])return 0;
		if(p[id - 1] == 1)r = mid;
		else l = mid;
	}
	l = 1,r = m,id = 0;
	int ol = 1,ori = 1;
	int x;
	while(l <= r){
		int mid = (l + r)/2;
		int omid = (ol + ori)/2;
		if(p[id] == 1)ori = omid;
		else ol = omid;
		if(p[id] == 1){
			cout << r << endl;
			cin >> x;
			if(!x)return 0;
			if(x == 1 && (r > omid)){
				r = mid;
				id++;
				continue;
			}
			l = mid;
			id++;
			continue;
		}
		else{
			cout << l << endl;
			cin >> x;
			if(!x)return 0;
			if(x == -1 && (l < omid)){
				l = mid;
				id++;
				continue;
			}
			r = mid;
			id++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int p[62];
int m,n;
int main(){
// 	freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	for(int i = 0;i < n;i++){
		cout << 1 << endl;
		cin >> p[i];
		if(!p[i])return 0;
		p[i] = p[i] == 1;
	}
	int l = 1,r = m,id = -1;
	int x;
	while(l <= r){
		id++;
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> x;
		if(!x)return 0;
		if(!p[id])x*=-1;
		if(x == 1)r = mid - 1;
		else l = mid + 1;
	}
}


#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int p[62];
int m,n;
int main(){
// 	freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	int l = 1,r = m,id = 0;
	while(l <= r){
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> p[id++];
		if(!p[id - 1])return 0;
		if(p[id - 1] == 1)r = mid - 1;
		else l = mid + 1;
	}
	for(int i = 0;i + id < n;i++)cout << 1 << endl;
	l = 1,r = m,id = 0;
	int x;
	while(l <= r){
		int mid = (l + r)/2;
		if(p[id] == 1){
			cout << r << endl;
			cin >> x;
			if(!x)return 0;
			if(x == 1){
				r = mid - 1;
				id++;
				continue;
			}
			l = mid + 1;
			id++;
			continue;
		}
		else{
			cout << l << endl;
			cin >> x;
			if(!x)return 0;
			if(x == -1){
				l = mid + 1;
				id++;
				continue;
			}
			r = mid - 1;
			id++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int p[62];
int m,n;
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	for(int i = 0;i < n;i++){
		cout << 1 << endl;
		cin >> p[i];
		if(!p[i])return 0;
	}
	int l = 1,r = m,id = -1;
	int x;
	while(l <= r){
		id = (id + 1)%n;
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> x;
		if(!x)return 0;
		if(p[id] == 1)x*=-1;
		if(x == 1)r = mid - 1;
		else l = mid + 1;
	}
}


#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int p[62];
int m,n;
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	int l = 1,r = m,id = 0;
	while(l <= r){
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> p[id++];
		if(!p[id - 1])return 0;
		if(p[id - 1] == 1)r = mid - 1;
		else l = mid + 1;
	}
	for(int i = 0;i + id < n;i++)cout << 1 << endl;
	l = 0,r = m,id = 0;
	int x;
	while(l <= r){
		int mid = (l + r)/2;
		if(p[id] == 1){
			cout << r << endl;
			cin >> x;
			if(!x)return 0;
			if(x == 1){
				r = mid - 1;
				id++;
				continue;
			}
			l = mid + 1;
			id++;
			continue;
		}
		else{
			cout << l << endl;
			cin >> x;
			if(!x)return 0;
			if(x == -1){
				l = mid + 1;
				id++;
				continue;
			}
			r = mid - 1;
			id++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int p[62];
int m,n;
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d%d",&m,&n);
	for(int i = 0;i < n;i++){
		cout << 1 << endl;
		cin >> p[i];
		if(!p[i])return 0;
	}
	int l = 1,r = m,id = -1;
	int x;
	while(l <= r){
		id++;
		int mid = (l + r)/2;
		cout << mid << endl;
		cin >> x;
		if(!x)return 0;
		if(p[id] == -1)x*=-1;
		if(x == 1)r = mid - 1;
		else l = mid + 1;
	}
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	//~ rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,1,30){
		i = r % (n+1) == 0? 1: r;

		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			return 0;
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	//~ rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,1,30){
		i = r % (n+1) == 0? 1: r;

		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,0,n-1){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 //rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,0,29){
		i = r % (n);
		mid = (a + b)/2;
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		cout<<mid<<"\n";
		//printf("%d\n", mid);
		fflush(stdout);
		cin>>resp;
		//scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 //~ rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,1,30){
		i = r % (n+1) == 0? 1: r;

		//printf("%d\n", mid);
		cout<<mid<<"\n";
		fflush(stdout);
		//~ scanf("%d", &resp);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		cout<<mid;
		cout << flush;
		cin>>resp;
		if(resp == 1)
			v[i] = 1;
	}
	int a=1,b=m;
	rep(i,1,n){
		cout<<mid;
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		cout<<mid;
		fflush(stdout);
		cin>>resp;
		if(resp == 1)
			v[i] = 1;
	}
	int a=1,b=m;
	rep(i,1,n){
		cout<<mid;
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = 1;
	rep(i,0,n-1){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 //rep(i,1,n) cout<<v[i]<<" ";
	int a=2,b=m, i;
	rep(r,0,29){
		i = r % (n);
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;

		mid = (a + b)/2;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	//~ rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,1,30){
		i = r % (n+1) == 0? 1: r;

		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			fflush(stdout);
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int query(int y)
{
    cout<<y<<"\n";
    fflush(stdout);
    int t;
    cin>>t;
    if(t==0||t==-2)
        exit(0);
    return t;
}

int main()
{
    int m,n;
    cin>>m>>n;
    int p[n];
    for(int i=0;i<n;i++)
    {
        int t=query((1+m)/2);
        p[i]=t==1;
    }
    int l=1,r=m;
    for(int q=0;;q++)
    {
        int y=(l+r)/2;
        int t=query(y);
        if(!p[q%n])
            t*=-1;
        if(t==1)
            l=y+1;
        else
            r=y-1;
    }
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 //rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,1,30){
		i = r % (n+1) == 0? 1: r;
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;

		mid = (a + b)/2;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,1,30){
		i = r % (n+1) == 0? 1: r;
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;

		mid = (a + b)/2;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = 1;
	rep(i,1,n){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 //rep(i,1,n) cout<<v[i]<<" ";
	int a=2,b=m, i;
	rep(r,1,30){
		i = r % (n+1) == 0? 1: r;
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;

		mid = (a + b)/2;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = m;
	rep(i,0,n-1){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 //rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m-1, i;
	rep(r,0,29){
		i = r % (n);
		mid = (a + b)/2;
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	int a=1,b=m;
	rep(i,1,30){
		i = i % (n+1);
		if(i == 0) i = 1;
		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 //rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,1,60){
		i = r % (n+1) == 0? 1: r;
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;

		mid = (a + b)/2;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = 1;
	rep(i,1,n){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 //rep(i,1,n) cout<<v[i]<<" ";
	int a=2,b=m, i;
	rep(r,1,60){
		i = r % (n+1) == 0? 1: r;
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;

		mid = (a + b)/2;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		cout<<mid<<"\n";
		//printf("%d\n", mid);
		fflush(stdout);
		cin>>resp;
		//scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,1,30){
		i = r % (n+1) == 0? 1: r;

		//printf("%d\n", mid);
		cout<<mid<<"\n";
		fflush(stdout);
		//~ scanf("%d", &resp);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = 1;
	rep(i,0,n-1){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 //rep(i,1,n) cout<<v[i]<<" ";
	int a=2,b=m, i;
	rep(r,0,29){
		i = r % (n);
		mid = (a + b)/2;
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", resp);
		if(resp == 1)
			v[i] = 1;
	}
	int a=1,b=m;
	rep(i,1,n){
		printf("%d\n", mid);
		cout << flush;
		scanf("%d", resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d\n", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	//~ rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,1,30){
		i = r % (n+1) == 0? 1: r;

		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d\n", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (2+m)/2;
	rep(i,1,n){
		cout<<1<<"\n";
		//printf("%d\n", mid);
		fflush(stdout);
		cin>>resp;
		//scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	 //~ rep(i,1,n) cout<<v[i]<<" ";
	int a=2,b=m, i;
	rep(r,1,30){
		i = r % (n+1) == 0? 1: r;

		//printf("%d\n", mid);
		cout<<mid<<"\n";
		fflush(stdout);
		//~ scanf("%d", &resp);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = (1+m)/2;
	rep(i,1,n){
		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == 1)
			v[i] = 1;
	}
	int a=1,b=m;
	rep(i,1,n){
		printf("%d\n", mid);
		fflush(stdout);
		scanf("%d", &resp);
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(v[i] == 1){
			if(resp == 1)
				a = mid + 1;
			else if(resp == -1)
				b = mid -1;
		}
		else if(v[i] == 0){
			if(resp == 1)
				b = mid -1;
			else if(resp == -1)
				a = mid + 1;
		}
		mid = (a + b)/2;
	}
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = m;
	rep(i,0,n-1){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == -1)
			v[i] = 1;
	}
	 //rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m-1, i;
	rep(r,0,29){
		i = r % (n);
		mid = (a + b)/2;
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;
	}
	cout<<"s";
	return 0;
}


//CazadorDivino
//No estas listo
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int v[101];

int main() {
	clr(v,0);
	int m, n, resp; cin>>m>>n;
	int mid = m;
	rep(i,0,n-1){
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}
		if(resp == -1)
			v[i] = 1;
	}
	 //rep(i,1,n) cout<<v[i]<<" ";
	int a=1,b=m, i;
	rep(r,0,29){
		i = r % (n);
		mid = (a + b)/2;
		cout<<mid<<"\n";
		fflush(stdout);
		cin>>resp;
		if(resp == 0 || resp == -2){
			exit(0);
		}

		if(v[i] == 0)
			resp *= -1;

		if(resp == 1)
			a = mid + 1;
		else if(resp == -1)
			b = mid -1;
	}
	cout<<"s";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
int n,m;
int A[35],B[1005];
const double EPS=1e-7;

signed main()
{
    sc(m)sc(n)
    int x;
    for(int i=1;i<=n;i++){
        cout<<1<<'\n';
        cout.flush();
        cin >> x;
        if(x==0){
            exit(0);
        }
        if(x == 1)A[i]=1;
        else A[i]=0;
    }
    int l = 1, r = m;
    for(int i=1;i<=30;i++){
        int mid = (l+r)/2;
        cout<<mid<<'\n';
        cout.flush();
        cin >> x;
        if(x==0){
            exit(0);
        }
        if(x == 1)l = mid+1;
        else r = mid-1;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
int n,m;
int A[35],B[1005];
const double EPS=1e-7;

signed main()
{
    sc(m)sc(n)
    int x;
    for(int i=1;i<=n;i++){
        cout<<0<<'\n';
        cout.flush();
        cin >> x;
        if(x==0){
            exit(0);
        }
        if(x == 1)A[i]=1;
        else A[i]=0;
    }
    int l = 1, r = m;
    for(int i=1;i<=30;i++){
        int mid = (l+r)/2;
        cout<<mid<<'\n';
        cout.flush();
        cin >> x;
        if(x==0){
            exit(0);
        }
        if(x == 1)l = mid+1;
        else r = mid-1;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
int n,m;
int A[35],B[1005];
const double EPS=1e-7;

signed main()
{
    sc(m)sc(n)
    int x;
    for(int i=1;i<=n;i++){
        cout<<1<<'\n';
        cout.flush();
        cin >> x;
        if(x == 0){
            exit(0);
        }
        if(x == 1)A[i]=1;
        else A[i]=0;
    }
    int l = 1, r = m;
    for(int i=1;i<=30;i++){
        int mid = (l+r)/2;
        if(A[(i)%n+1])
            cout<<mid<<'\n';
        else cout<<(-mid)<<'\n';
        cout.flush();
        cin >> x;
        if(x == 0){
            exit(0);
        }
        if((x == 1&&A[i%n+1])||(x==-1&&A[i%n+1]==0))l = mid + 1;
        else r = mid - 1;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
int n,m;
int A[35],B[1005];
const double EPS=1e-7;

signed main()
{
    sc(m)sc(n)
    int x;
    for(int i=1;i<=n;i++){
        cout<<1<<'\n';
        cout.flush();
        cin >> x;
        if(x==0){
            exit(0);
        }
        if(x == 1)A[i]=1;
        else A[i]=0;
    }
    int l = 1, r = m;
    for(int i=1;i<=30;i++){
        int mid = (l+r)/2;
        cout<<mid<<'\n';
        cout.flush();
        cin >> x;
        if(x==0){
            exit(0);
        }
        if((x == 1&&A[i])||(x==-1&&A[i]==0))l = mid+1;
        else r = mid-1;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
int n,m;
int A[35],B[1005];
const double EPS=1e-7;

signed main()
{
    sc(m)sc(n)
    int x;
    for(int i=1;i<=n;i++){
        cout<<1<<'\n';
        cout.flush();
        cin >> x;
        if(x == 0){
            exit(0);
        }
        if(x == 1)A[i]=1;
        else A[i]=0;
    }
    int l = 1, r = m;
    for(int i=1;i<=30;i++){
        int mid = (l+r)/2;
        if(A[i])
            cout<<mid<<'\n';
        else cout<<(-mid)<<'\n';
        cout.flush();
        cin >> x;
        if(x == 0){
            exit(0);
        }
        if((x == 1&&A[i])||(x==-1&&A[i]==0))l = mid + 1;
        else r = mid - 1;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
int n,m;
int A[35],B[1005];
const double EPS=1e-7;

signed main()
{
    sc(m)sc(n)
    int x;
    for(int i=1;i<=n;i++){
        cout<<1<<'\n';
        cout.flush();
        cin >> x;
        if(x == 0){
            exit(0);
        }
        if(x == 1)A[i]=1;
        else A[i]=0;
    }
    int l = 1, r = m;
    for(int i=1;i<=30;i++){
        int mid = (l+r)/2;
        if(A[(i-1)%n+1])
            cout<<mid<<'\n';
        else cout<<(-mid)<<'\n';
        cout.flush();
        cin >> x;
        if(x == 0){
            exit(0);
        }
        if((x == 1&&A[(i-1)%n+1])||(x==-1&&A[(i-1)%n+1]==0))l = mid + 1;
        else r = mid - 1;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
int n,m;
int A[35],B[1005];
const double EPS=1e-7;

signed main()
{
    sc(m)sc(n)
    int x;
    for(int i=1;i<=n;i++){
        cout<<1<<'\n';
        cout.flush();
        cin >> x;
        if(x == 0){
            exit(0);
        }
        if(x == 1)A[i]=1;
        else A[i]=0;
    }
    int l = 1, r = m;
    for(int i=1;i<=30;i++){
        int mid = (l+r)/2;
        cout<<mid<<'\n';

        cout.flush();
        cin >> x;
        if(x == 0){
            exit(0);
        }
        if((x == 1&&A[(i-1)%n+1])||(x==-1&&A[(i-1)%n+1]==0))l = mid + 1;
        else r = mid - 1;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
int n,m;
int A[35],B[1005];
const double EPS=1e-7;

signed main()
{
    sc(m)sc(n)
    int x;
    for(int i=1;i<=n;i++){
        cout<<1<<'\n';
        cout.flush();
        cin >> x;
        if(x == 0){
            exit(0);
        }
        if(x == 1)A[i]=1;
        else A[i]=0;
    }
    int l = 1, r = m;
    for(int i=1;i<=30;i++){
        int mid = (l+r)/2;
        if(A[(i)%n+1])
            cout<<mid<<'\n';
        else cout<<(-mid)<<'\n';
        cout.flush();
        cin >> x;
        if(x == 0){
            exit(0);
        }
        if((x == 1&&A[i])||(x==-1&&A[i]==0))l = mid + 1;
        else r = mid - 1;
    }
}


//  amiD
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define Endl '\n'
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
using namespace std;
int a[111];
int main(){
    int m, n;
	cin>>m>>n;
    for (int i=0;i<n;i++){
        cout<<m<< endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if (amid==0)exit(0);
        if(amid==-1)a[i]=1;
        else a[i]=0;
    }
    ll st = 1, en = m, c=0;
    while(st+1<en){
        ll md=(st + en)/2;
        cout<<md<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(!a[c])amid=-amid;
        if(amid==-1)st=md;
        if(!amid)exit(0);
        if(amid==1)en=md;
        c++;
        c%=n;
    }
}


//  amiD
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define Endl '\n'
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
using namespace std;
int a[111];
int main(){
    int m, n;
	cin>>m>>n;
    for (int i=0;i<n;i++){
        cout<<m<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(amid==0)exit(0);
        if(amid==1)a[i]=1;
        else a[i]=0;
    }
    ll st = 1, en = m, c=0;
    while(st+1<en){
        ll md=(st + en)/2;
        cout<<md<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(!a[c])amid=-amid;
        if(amid==-1)st=md;
        if(!amid)exit(0);
        if(amid==1)en=md;
        c++;
        c%=n;
    }
}


//  amiD
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define Endl '\n'
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
using namespace std;
int a[111];
int main(){
    int m, n;
	cin>>m>>n;
    for (int i=0;i<n;i++){
        cout<<m<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(amid==0)exit(0);
        if(amid==1)a[i]=1;
        else a[i]=0;
    }
    ll st = 1, en = m, c=0;
    for(int i=n;i<60;i++){
        ll md=(st + en)/2;
        cout<<md<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(!a[c])amid=-amid;
        if(amid==-1)st=md;
        if(!amid)exit(0);
        if(amid==1)en=md;
        c++;
        c%=n;
    }
}


//  amiD
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define Endl '\n'
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
using namespace std;
int a[111];
int main(){
    int m, n;
	cin>>m>>n;
    for (int i=0;i<n;i++){
        cout<<m<< endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if (amid==0)exit(0);
        if(amid==-1)a[i]=1;
        else a[i]=0;
    }
    int st = 0, en = m, c=0;
    for(int i=n;i<60;i++){
        int md=(st + en)/2;
        cout<<md<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(!a[c])amid=-amid;
        if(amid==-1)st=md;
        if(!amid)exit(0);
        if(amid==1)en=md;
        c++;
        c%=n;
    }
}


//  amiD
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define Endl '\n'
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
using namespace std;
char a[111];
int main(){
    int m, n;
	cin>>m>>n;
    for (int i=0;i<n;i++){
        cout<<m<< endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if (amid==0)exit(0);
        if(amid==-1)a[i]=1;
        else a[i]=0;
    }
    int st = 0, en = m, c=0;
    for(int i=n;i<60;i++){
        int md=(st + en)/2;
        cout<<md<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(!a[c])amid=-amid;
        if(amid==-1)st=md;
        if(!amid)exit(0);
        if(amid==1)en=md;
        c++;
        c%=n;
    }
}


//  amiD
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define Endl '\n'
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
using namespace std;
char a[111];
int main(){
    int m, n;
	cin>>m>>n;
    for (int i=0;i<n;i++){
        cout<<m<< endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if (amid==0)return 0;
        if(amid==-1)a[i]=1;
        else a[i]=0;
    }
    int st = 0, en = m, c=0;
    for(int i=n;i<60;i++){
        int md=(st + en)/2;
        cout<<md<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(!a[c])amid=-amid;
        if(amid==-1)st=md;
        if(!amid)return 0;
        if(amid==1)en=md;
        c++;
        c%=n;
    }
}


//  amiD
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define Endl '\n'
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
using namespace std;
int a[111];
int main(){
    int m, n;
	cin>>m>>n;
    for (int i=0;i<n;i++){
        cout<<m<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(amid==0)exit(0);
        if(amid==1)a[i]=1;
        else a[i]=0;
    }
    ll st = 1, en = m, c=0;
    for(int i=n;i<60;i++){
        ll md=(st + en)/2;
        cout<<md<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(!a[c])amid=-amid;
        if(amid==-1)st=md+1;
        if(!amid)exit(0);
        if(amid==1)en=md-1;
        c++;
        c%=n;
    }
}


//  amiD
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define Endl '\n'
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
using namespace std;
int a[111];
int main(){
    int m, n;
	cin>>m>>n;
    for (int i=0;i<n;i++){
        cout<<m<< endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if (amid==0)exit(0);
        if(amid==-1)a[i]=1;
        else a[i]=0;
    }
    int st = 1, en = m, c=0;
    for(int i=n;i<60;i++){
        int md=(st + en)/2;
        cout<<md<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(!a[c])amid=-amid;
        if(amid==-1)st=md;
        if(!amid)exit(0);
        if(amid==1)en=md;
        c++;
        c%=n;
    }
}


//  amiD
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define Endl '\n'
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
using namespace std;
char a[111];
int main(){
    int m, n;
	cin>>m>>n;
    for (int i=0;i<n;i++){
        cout<<1<< endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if (amid==0)return 0;
        a[i] == (amid == -1);
    }
    int st = -1, en = m, c=0;
    while (st+1<en){
        int md=(st + en)/2;
        cout<<md<<endl;
        fflush(stdout);
        int amid;
        cin>>amid;
        if(!a[c])amid=-amid;
        if(amid==-1)st=md;
        if(!amid)return 0;
        if(amid==1)en=md;
        c++;
    }

}


#include <bits/stdc++.h>
#define CIOS ios::sync_with_stdio(false);
#define For(i, a, b) for(register int i = a; i <= b; i++)
#define Rof(i, a, b) for(register int i = a; i >= b; i--)
#define DEBUG(x) cerr << "DEBUG" << x << " >>> ";
using namespace std;

typedef unsigned long long ull;
typedef unsigned long long ll;

template <typename T>
inline void read(T &f) {
	f = 0; T fu = 1; char c = getchar();
	while(c < '0' || c > '9') {if(c == '-') fu = -1; c = getchar();}
	while(c >= '0' && c <= '9') {f = (f << 3) + (f << 1) + (c & 15); c = getchar();}
	f *= fu;
}

template <typename T>
void print(T x) {
	if(x < 0) putchar('-'), x = -x;
	if(x < 10) putchar(x + 48);
	else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
	print(x); putchar(t);
}

const ll INF = 9223372036854775807ll;

ll n, k, t[100];
int T;

bool check(ll x, ll y) {
	double a = (double)x / INF;
	double b = (double)y / INF;
	return (a * b - 1e-4) >= 1;
}

int main() {
	read(T); t[0] = 0; t[1] = 1;
	for(register int i = 2; i <= 31; i++) t[i] = t[i - 1] + (1ll << i - 1) * (1ll << i - 1);
	while(T--) {
		read(n); read(k); int ans = -1;
		if(n > 31) {
			printf("YES %d\n", n - 1);
			continue;
		}
		ll now = 1, nowcan = t[n - 1], cnt = 1;
		for(register int i = 2; i <= n + 1 && now <= k && i <= 31; i++) {
			if(k - now <= nowcan) {
				ans = n - i + 1;
				break;
			}
			if(i == n + 1) break;
//			cout << now << " " << nowcan << " " << cnt << endl;
			now += (cnt + 2ll);
			cnt += 4ll;
			if(check(t[n - i], cnt)) nowcan = INF;
			else nowcan += t[n - i] * cnt;
		}
		if(ans != -1) printf("YES %d\n", ans);
		else printf("NO\n");
	}
	return 0;
}


#include <bits/stdc++.h>
#define CIOS ios::sync_with_stdio(false);
#define For(i, a, b) for(register int i = a; i <= b; i++)
#define Rof(i, a, b) for(register int i = a; i >= b; i--)
#define DEBUG(x) cerr << "DEBUG" << x << " >>> ";
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
inline void read(T &f) {
	f = 0; T fu = 1; char c = getchar();
	while(c < '0' || c > '9') {if(c == '-') fu = -1; c = getchar();}
	while(c >= '0' && c <= '9') {f = (f << 3) + (f << 1) + (c & 15); c = getchar();}
	f *= fu;
}

template <typename T>
void print(T x) {
	if(x < 0) putchar('-'), x = -x;
	if(x < 10) putchar(x + 48);
	else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
	print(x); putchar(t);
}

ll n, k, t[100];
int T;

int main() {
	read(T); t[0] = 0; t[1] = 1; t[2] = 2;
	for(register int i = 3; i <= 31; i++) t[i] = t[i - 1] + (1ll << i - 2) * (1ll << i - 2);
	while(T--) {
		read(n); read(k); int ans = -1;
		if(n > 31) {
			printf("YES %d\n", n - 1);
			continue;
		}
		ll now = 1, nowcan = n == 1 ? 0 : (1ll << (n - 2)), cnt = 1;
		for(register int i = 2; i <= n + 1 && now <= k && i <= 31; i++) {
			if(k - now <= nowcan) {
				ans = n - i + 1;
				break;
			}
			if(i == n + 1) break;
			now += (cnt + 2ll);
			nowcan += t[n - i] * cnt;
			cnt += 4ll;
		}
		if(ans != -1) printf("YES %d\n", ans);
		else printf("NO\n");
	}
	return 0;
}


#include <bits/stdc++.h>
#define CIOS ios::sync_with_stdio(false);
#define For(i, a, b) for(register int i = a; i <= b; i++)
#define Rof(i, a, b) for(register int i = a; i >= b; i--)
#define DEBUG(x) cerr << "DEBUG" << x << " >>> ";
using namespace std;

typedef unsigned long long ull;
typedef __int128 ll;

template <typename T>
inline void read(T &f) {
	f = 0; T fu = 1; char c = getchar();
	while(c < '0' || c > '9') {if(c == '-') fu = -1; c = getchar();}
	while(c >= '0' && c <= '9') {f = (f << 3) + (f << 1) + (c & 15); c = getchar();}
	f *= fu;
}

template <typename T>
void print(T x) {
	if(x < 0) putchar('-'), x = -x;
	if(x < 10) putchar(x + 48);
	else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
	print(x); putchar(t);
}

ll n, k, t[100];
int T;

int main() {
	read(T); t[0] = 0; t[1] = 1;
	for(register int i = 2; i <= 31; i++) t[i] = t[i - 1] + (1ll << i - 1) * (1ll << i - 1);
	while(T--) {
		read(n); read(k); int ans = 0;
		if(n >= 31 || k <= t[n]) {
			printf("YES ");
			print(n - 1, '\n');
			continue;
		}
		ll now = 1, nowcan = (1ll << (n - 1)), cnt = 1;
		for(register int i = 2; i <= n && now <= k; i++) {
			if(k - now <= nowcan) {
				ans = n - i;
				break;
			}
			now += (cnt + 2ll);
			nowcan += (1ll << (n - i)) * cnt;
			cnt += 4;
		}
		if(ans) printf("YES %d\n", ans);
		else printf("NO\n");
	}
	return 0;
}


/*

@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise
I won't let it go. I'll build myself again like a fighter gets back up after
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ul;
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define vi vector<ll>
#define vii vector<vector<ll> >
#define vpi vector<pair<ll,ll> >
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"YES\n"
#define no (cout<<"NO\n")
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx = 1e9+7;

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

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}

/* When life hits hard and you get a WA
   Check for overflow
   Check for array bounds
   Fucking check for n=1? case. g++ would give you correct answer. So dry run for n=1.
   Fucking do something.
*/
template<typename... T> void pr(T&&... args){ ((cout << args << " "), ...); cout << "\n"; }
template<typename... T> void rd(T&&... args){ ((cin >> args), ...); }
template<class T> void printv(T &v, bool one_indexed, ll size){if(size==-1) size=v.size(); if(one_indexed){rep1(i,size-1) cout << v[i] << " ";} else rep(i,size) cout << v[i] << " "; cout << "\n";}
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dx[] = {0,1,0,-1,1,-1,1,-1};
int dy[] = {1,0,-1,0,1,1,-1,-1};

ll n,k;
ll dp[32], dp2[32];
void solve(){
    rd(n,k);
    ll kk=3*k+1,c=0;
    while(kk){
        kk/=4;
        c++;
    }
    if(n-1>=c){
        pr("YES",n-1);
        return;
    }
    ll i=1,ans=0;
    for(i=1; i<=n; i++){
        if((ans+ (dp2[i]-1)+((dp2[i+1]-3)*(dp[n-i]-1))/3)>=k)
            break;
        ans+=dp2[i]-1+((dp2[i+1]-3)*(dp[n-i]-1))/3;
    }
    if(i<=n)
        pr("YES",n-i);
    else
        no;

}

int main(){
    fsync
    ll test=1;
    dp[0]=1,dp2[0]=1;
    rep1(i,31)
        dp[i]=dp[i-1]*4,dp2[i]=dp2[i-1]*2;
    cin >> test;
    while(test--){
        solve();
    }

}

// Observe first. (Binary search, Two pointers), prefix sums, dp, greedy


/*

@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise
I won't let it go. I'll build myself again like a fighter gets back up after
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ul;
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define vi vector<ll>
#define vii vector<vector<ll> >
#define vpi vector<pair<ll,ll> >
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"YES\n"
#define no (cout<<"NO\n")
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx =  1e9+7;

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

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}

/* When life hits hard and you get a WA
   Check for overflow
   Check for array bounds
   Fucking check for n=1? case. g++ would give you correct answer. So dry run for n=1.
   Fucking do something.
*/
template<typename... T> void pr(T&&... args){ ((cout << args << " "), ...); cout << "\n"; }
template<typename... T> void rd(T&&... args){ ((cin >> args), ...); }
template<class T> void printv(T &v, bool one_indexed, ll size){if(size==-1) size=v.size(); if(one_indexed){rep1(i,size-1) cout << v[i] << " ";} else rep(i,size) cout << v[i] << " "; cout << "\n";}
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dx[] = {0,1,0,-1,1,-1,1,-1};
int dy[] = {1,0,-1,0,1,1,-1,-1};

ll n,k;
void solve(){
    rd(n,k);
    ll x=1,y=0,z=0;
    while(y<=k){
        y+=x;
        x*=4;
        z++;
    }
    if(z>n){
        no;
        return;
    }
    if((y-1)/4+1>=k)
        z--;
    pr("YES",n-z);

}

int main(){
    fsync
    ll test=1;
    cin >> test;
    while(test--){
        solve();
    }

}

// Observe first. (Binary search, Two pointers), prefix sums, dp, greedy


/*

@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise
I won't let it go. I'll build myself again like a fighter gets back up after
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ul;
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define vi vector<ll>
#define vii vector<vector<ll> >
#define vpi vector<pair<ll,ll> >
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"YES\n"
#define no (cout<<"NO\n")
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx = 1e9+7;

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

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}

/* When life hits hard and you get a WA
   Check for overflow
   Check for array bounds
   Fucking check for n=1? case. g++ would give you correct answer. So dry run for n=1.
   Fucking do something.
*/
template<typename... T> void pr(T&&... args){ ((cout << args << " "), ...); cout << "\n"; }
template<typename... T> void rd(T&&... args){ ((cin >> args), ...); }
template<class T> void printv(T &v, bool one_indexed, ll size){if(size==-1) size=v.size(); if(one_indexed){rep1(i,size-1) cout << v[i] << " ";} else rep(i,size) cout << v[i] << " "; cout << "\n";}
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dx[] = {0,1,0,-1,1,-1,1,-1};
int dy[] = {1,0,-1,0,1,1,-1,-1};

ll n,k;
ll dp[32], dp2[32];
void solve(){
    rd(n,k);
    ll kk=3*k+1,c=0;
    while(kk){
        kk/=4;
        c++;
    }
    if(n-1>=c){
        pr("YES",n-1);
        return;
    }
    ll i=1,ans=0;
    for(i=1; i<=n; i++){
        if((ans+ (dp2[i-1]-1)+((dp2[i+1]-3)*(dp[n-i]-1))/3)>=k)
            break;
        ans+=dp2[i-1]-1+((dp2[i+1]-3)*(dp[n-i]-1))/3;
    }
    if(i<=n)
        pr("YES",n-i);
    else
        no;

}

int main(){
    fsync
    ll test=1;
    dp[0]=1,dp2[0]=1;
    rep1(i,31)
        dp[i]=dp[i-1]*4,dp2[i]=dp2[i-1]*2;
    cin >> test;
    while(test--){
        solve();
    }

}

// Observe first. (Binary search, Two pointers), prefix sums, dp, greedy


/*

@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise
I won't let it go. I'll build myself again like a fighter gets back up after
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ul;
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define vi vector<ll>
#define vii vector<vector<ll> >
#define vpi vector<pair<ll,ll> >
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"YES\n"
#define no (cout<<"NO\n")
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx = 1e9+7;

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

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}

/* When life hits hard and you get a WA
   Check for overflow
   Check for array bounds
   Fucking check for n=1? case. g++ would give you correct answer. So dry run for n=1.
   Fucking do something.
*/
template<typename... T> void pr(T&&... args){ ((cout << args << " "), ...); cout << "\n"; }
template<typename... T> void rd(T&&... args){ ((cin >> args), ...); }
template<class T> void printv(T &v, bool one_indexed, ll size){if(size==-1) size=v.size(); if(one_indexed){rep1(i,size-1) cout << v[i] << " ";} else rep(i,size) cout << v[i] << " "; cout << "\n";}
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dx[] = {0,1,0,-1,1,-1,1,-1};
int dy[] = {1,0,-1,0,1,1,-1,-1};

ll n,k;
ll dp[32], dp2[32];
void solve(){
    rd(n,k);
    if(n==2 && k==3){
        no;
        return;
    }
    ll kk=3*k+1,c=0;
    while(kk){
        kk/=4;
        c++;
    }
    if(n-1>=c){
        pr("YES",n-1);
        return;
    }
    ll i=1,ans=0;
    for(i=1; i<=n; i++){
        if((ans+ (dp2[i]-1)+((dp2[i+1]-3)*(dp[n-i]-1))/3)>=k)
            break;
        ans+=dp2[i]-1+((dp2[i+1]-3)*(dp[n-i]-1))/3;
    }
    if(i<=n)
        pr("YES",n-i);
    else
        no;

}

int main(){
    fsync
    ll test=1;
    dp[0]=1,dp2[0]=1;
    rep1(i,31)
        dp[i]=dp[i-1]*4,dp2[i]=dp2[i-1]*2;
    cin >> test;
    while(test--){
        solve();
    }

}

// Observe first. (Binary search, Two pointers), prefix sums, dp, greedy


/*

@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise
I won't let it go. I'll build myself again like a fighter gets back up after
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ul;
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define vi vector<ll>
#define vii vector<vector<ll> >
#define vpi vector<pair<ll,ll> >
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"YES\n"
#define no (cout<<"NO\n")
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx = 1e9+7;

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

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}

/* When life hits hard and you get a WA
   Check for overflow
   Check for array bounds
   Fucking check for n=1? case. g++ would give you correct answer. So dry run for n=1.
   Fucking do something.
*/
template<typename... T> void pr(T&&... args){ ((cout << args << " "), ...); cout << "\n"; }
template<typename... T> void rd(T&&... args){ ((cin >> args), ...); }
template<class T> void printv(T &v, bool one_indexed, ll size){if(size==-1) size=v.size(); if(one_indexed){rep1(i,size-1) cout << v[i] << " ";} else rep(i,size) cout << v[i] << " "; cout << "\n";}
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dx[] = {0,1,0,-1,1,-1,1,-1};
int dy[] = {1,0,-1,0,1,1,-1,-1};

ll n,k;
ll dp[32], dp2[32];
void solve(){
    rd(n,k);
    ll kk=3*k+1,c=0;
    while(kk){
        kk/=4;
        c++;
    }
    if(n-1>=c){
        pr("YES",n-1);
        return;
    }
    ll i=1,ans=0;
    for(i=1; i<=n; i++){
        if((ans+ dp2[i-1]+((dp2[i+1]-3)*(dp[n-i]-1))/3)>=k)
            break;
        ans+=dp2[i-1]+((dp2[i+1]-3)*(dp[n-i]-1))/3;
    }
    if(i<=n)
        pr("YES",n-i);
    else
        no;

}

int main(){
    fsync
    ll test=1;
    dp[0]=1,dp2[0]=1;
    rep1(i,31)
        dp[i]=dp[i-1]*4,dp2[i]=dp2[i-1]*2;
    cin >> test;
    while(test--){
        solve();
    }

}

// Observe first. (Binary search, Two pointers), prefix sums, dp, greedy


/*

@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise
I won't let it go. I'll build myself again like a fighter gets back up after
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ul;
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define vi vector<ll>
#define vii vector<vector<ll> >
#define vpi vector<pair<ll,ll> >
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"YES\n"
#define no (cout<<"NO\n")
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx =  1e9+7;

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

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}

/* When life hits hard and you get a WA
   Check for overflow
   Check for array bounds
   Fucking check for n=1? case. g++ would give you correct answer. So dry run for n=1.
   Fucking do something.
*/
template<typename... T> void pr(T&&... args){ ((cout << args << " "), ...); cout << "\n"; }
template<typename... T> void rd(T&&... args){ ((cin >> args), ...); }
template<class T> void printv(T &v, bool one_indexed, ll size){if(size==-1) size=v.size(); if(one_indexed){rep1(i,size-1) cout << v[i] << " ";} else rep(i,size) cout << v[i] << " "; cout << "\n";}
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dx[] = {0,1,0,-1,1,-1,1,-1};
int dy[] = {1,0,-1,0,1,1,-1,-1};

ll n,k;
void solve(){
    rd(n,k);
    ll x=1,y=0,z=0;
    while(y<=k){
        y+=x;
        x*=4;
        z++;
    }
    if((y-1)/4+1>=k)
        z--;
    if(z>n)
        no;
    else{
        pr("YES",n-z);
    }

}

int main(){
    fsync
    ll test=1;
    cin >> test;
    while(test--){
        solve();
    }

}

// Observe first. (Binary search, Two pointers), prefix sums, dp, greedy