#include<bits/stdc++.h>
#include <iomanip>
#include <random>
#include <cassert>
#define ll long long int
#define ld long double
#define f first
#define inf 100000000000000000
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define s second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define Sort(a) sort(a.begin(),a.end());
using namespace std;
ll const mod=998244353;
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
int rand_rng(int l, int r) {
	uniform_int_distribution<int> p(l, r);
	return p(rng);
}
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set os.find_by_order os.order_of_key
// b/w l and r os.order_of_key(r+1)-order_of_key(l)

int arr1[100009];
int parent[100009];
vector<ll> sieve;
void sievefun(ll n){
    for(ll i=2;i<=n;i++){
        if(arr1[i]==0){
              parent[i]=i;
            for(ll j=i*i;j<=n;j+=i){
           		if(arr1[j]==0)parent[j]=i;
                arr1[j]=1;
            }
        }
    }
    // for(int i=2;i<=n;i++){
    // 	if(arr1[i]==0)sieve.pb(i);
    // }
}
ll power(ll x, ll y,ll m) {
	ll temp;
	if( y == 0||x==1)
		return 1;
	temp = power(x, y/2,m)%m;
	if (y%2 == 0)
		return ((temp)*(temp))%m;
	else
		return (((x)%m)*((temp*temp)%m))%m;
}

// ll fac[1000009];
// void factorial(){
// 	fac[0]=1;
// 	for(int i=1;i<=1000000;i++)fac[i]=(i*fac[i-1])%mod;
// }
// ll ncr(ll n,ll r){
// 	return (fac[n]*((power(fac[r],mod-2)*power(fac[n-r],mod-2))%mod))%mod;
// }
int const N=200009;

int main()
{	//sievefun(20000);
	// ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,x,y;
	cin>>n;
	set<ll> st,on,off;
	int ind=1;
	if(n<=3){
		cout<<0<<endl;
		return 0;
	}
	while(ind<=n-1){
		st.insert(ind);
		on.insert(ind);
		off.insert(ind);
		ind+=2;
	}
	while(st.size()>1){
		ll node=*(st.begin());
		st.erase(st.begin());
		ll node2=*(st.begin());
		st.erase(st.begin());
		cout<<"2 "<<node<<" "<<node2<<endl;
		on.insert(node);
		on.insert(node2);
		cin>>x;
		if(x==-1)return 0;
		y=x+1;
		if(x==n)y=1;
		if(on.find(x)!=on.end()){
			on.erase(x);
			st.insert(x);
		}
		if(on.find(y)!=on.end()){
			on.erase(y);
			st.insert(y);
		}
	}
	ll node=*(st.begin());
	vi vec;
	vec.pb(*st.begin());
	for(int i=2;i<n;i+=4){
		if(i+1!=*st.begin()&&i-1!=*st.begin())
		vec.pb(i);
	}
	// for(auto i:vec)cout<<i<<" ";
	// 	cout<<endl;
	if(vec.size()<4||n<=10)
		cout<<0<<endl;
	else{
		cout<<vec.size()<<" ";
		for(auto i:vec)cout<<i<<" ";
			cout<<endl;
		cin>>x;
		cout<<0<<endl;
	}

}


#include<bits/stdc++.h>
#include <iomanip>
#include <random>
#include <cassert>
#define ll long long int
#define ld long double
#define f first
#define inf 100000000000000000
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define s second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define Sort(a) sort(a.begin(),a.end());
using namespace std;
ll const mod=998244353;
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
int rand_rng(int l, int r) {
	uniform_int_distribution<int> p(l, r);
	return p(rng);
}
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set os.find_by_order os.order_of_key
// b/w l and r os.order_of_key(r+1)-order_of_key(l)

int arr1[100009];
int parent[100009];
vector<ll> sieve;
void sievefun(ll n){
    for(ll i=2;i<=n;i++){
        if(arr1[i]==0){
              parent[i]=i;
            for(ll j=i*i;j<=n;j+=i){
           		if(arr1[j]==0)parent[j]=i;
                arr1[j]=1;
            }
        }
    }
    // for(int i=2;i<=n;i++){
    // 	if(arr1[i]==0)sieve.pb(i);
    // }
}
ll power(ll x, ll y,ll m) {
	ll temp;
	if( y == 0||x==1)
		return 1;
	temp = power(x, y/2,m)%m;
	if (y%2 == 0)
		return ((temp)*(temp))%m;
	else
		return (((x)%m)*((temp*temp)%m))%m;
}

// ll fac[1000009];
// void factorial(){
// 	fac[0]=1;
// 	for(int i=1;i<=1000000;i++)fac[i]=(i*fac[i-1])%mod;
// }
// ll ncr(ll n,ll r){
// 	return (fac[n]*((power(fac[r],mod-2)*power(fac[n-r],mod-2))%mod))%mod;
// }
int const N=200009;

int main()
{	//sievefun(20000);
	// ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,x,y;
	cin>>n;
	set<ll> st,on,off;
	int ind=1;
	if(n<=3){
		cout<<0<<endl;
		return 0;
	}
	ll num=0;
	ind=0;
	for(int i=1;i<=n;i++){
		if(n-(n/i)-i+1>num){
			num=n-(n/i)-i+1;
			ind=i;
		}
	}
	// cout<<ind<<"\n";
	for(int i=1;i<=n;i+=ind){
		if((i-1)%(ind)==0)continue;
		off.insert(i);
	}
	while(off.size()>=ind){
		vi out;
		forn(i,ind){
			out.pb(*(off.begin()));
			on.insert(*(off.begin()));
			off.erase(*(off.begin()));
		}
		cout<<out.size()<<" ";
		for(auto i:out)cout<<i<<" ";
			cout<<endl;
		cin>>x;
		forn(i,ind){
			if(on.find(x)!=on.end()){
				on.erase(x);
				off.insert(x);
			}
			x++;
			if(x>n)x-=n;
		}
	}
	cout<<0<<endl;

}


#include<bits/stdc++.h>
#include <iomanip>
#include <random>
#include <cassert>
#define ll long long int
#define ld long double
#define f first
#define inf 100000000000000000
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define s second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define Sort(a) sort(a.begin(),a.end());
using namespace std;
ll const mod=998244353;
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
int rand_rng(int l, int r) {
	uniform_int_distribution<int> p(l, r);
	return p(rng);
}
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set os.find_by_order os.order_of_key
// b/w l and r os.order_of_key(r+1)-order_of_key(l)

int arr1[100009];
int parent[100009];
vector<ll> sieve;
void sievefun(ll n){
    for(ll i=2;i<=n;i++){
        if(arr1[i]==0){
              parent[i]=i;
            for(ll j=i*i;j<=n;j+=i){
           		if(arr1[j]==0)parent[j]=i;
                arr1[j]=1;
            }
        }
    }
    // for(int i=2;i<=n;i++){
    // 	if(arr1[i]==0)sieve.pb(i);
    // }
}
ll power(ll x, ll y,ll m) {
	ll temp;
	if( y == 0||x==1)
		return 1;
	temp = power(x, y/2,m)%m;
	if (y%2 == 0)
		return ((temp)*(temp))%m;
	else
		return (((x)%m)*((temp*temp)%m))%m;
}

// ll fac[1000009];
// void factorial(){
// 	fac[0]=1;
// 	for(int i=1;i<=1000000;i++)fac[i]=(i*fac[i-1])%mod;
// }
// ll ncr(ll n,ll r){
// 	return (fac[n]*((power(fac[r],mod-2)*power(fac[n-r],mod-2))%mod))%mod;
// }
int const N=200009;

int main()
{	//sievefun(20000);
	// ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,x,y;
	cin>>n;
	set<ll> st,on,off;
	int ind=1;
	if(n<=3){
		cout<<0<<endl;
		return 0;
	}
	ll num=0;
	ind=0;
	for(int i=1;i<=n;i++){
		if(n-(n/i)-i+1>num){
			num=n-(n+i-1/i)-i+1;
			ind=i;
		}
	}
	// cout<<ind<<"\n";
	for(int i=1;i<=n;i++){
		if((i-1)%(ind)==0)continue;
		off.insert(i);
	}

	while(off.size()>=ind){
		vi out;
		forn(i,ind){
			out.pb(*(off.begin()));
			on.insert(*(off.begin()));
			off.erase(*(off.begin()));
		}
		cout<<out.size()<<" ";
		for(auto i:out)cout<<i<<" ";
			cout<<endl;
		cin>>x;
		forn(i,ind){
			if(on.find(x)!=on.end()){
				on.erase(x);
				off.insert(x);
			}
			x++;
			if(x>n)x-=n;
		}
	}
	cout<<0<<endl;

}


#include<bits/stdc++.h>
#include <iomanip>
#include <random>
#include <cassert>
#define ll long long int
#define ld long double
#define f first
#define inf 100000000000000000
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define s second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define Sort(a) sort(a.begin(),a.end());
using namespace std;
ll const mod=998244353;
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
int rand_rng(int l, int r) {
	uniform_int_distribution<int> p(l, r);
	return p(rng);
}
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set os.find_by_order os.order_of_key
// b/w l and r os.order_of_key(r+1)-order_of_key(l)

int arr1[100009];
int parent[100009];
vector<ll> sieve;
void sievefun(ll n){
    for(ll i=2;i<=n;i++){
        if(arr1[i]==0){
              parent[i]=i;
            for(ll j=i*i;j<=n;j+=i){
           		if(arr1[j]==0)parent[j]=i;
                arr1[j]=1;
            }
        }
    }
    // for(int i=2;i<=n;i++){
    // 	if(arr1[i]==0)sieve.pb(i);
    // }
}
ll power(ll x, ll y,ll m) {
	ll temp;
	if( y == 0||x==1)
		return 1;
	temp = power(x, y/2,m)%m;
	if (y%2 == 0)
		return ((temp)*(temp))%m;
	else
		return (((x)%m)*((temp*temp)%m))%m;
}

// ll fac[1000009];
// void factorial(){
// 	fac[0]=1;
// 	for(int i=1;i<=1000000;i++)fac[i]=(i*fac[i-1])%mod;
// }
// ll ncr(ll n,ll r){
// 	return (fac[n]*((power(fac[r],mod-2)*power(fac[n-r],mod-2))%mod))%mod;
// }
int const N=200009;

int main()
{	//sievefun(20000);
	// ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,x,y;
	cin>>n;
	set<ll> st,on,off;
	int ind=1;
	if(n<=3){
		cout<<0<<endl;
		return 0;
	}
	while(ind<=n-1){
		st.insert(ind);
		on.insert(ind);
		off.insert(ind);
		ind+=2;
	}
	while(st.size()>1){
		ll node=*(st.begin());
		st.erase(st.begin());
		ll node2=*(st.begin());
		st.erase(st.begin());
		cout<<"2 "<<node<<" "<<node2<<endl;
		on.insert(node);
		on.insert(node2);
		cin>>x;
		if(x==-1)return 0;
		y=x+1;
		if(x==n)y=1;
		if(on.find(x)!=on.end()){
			on.erase(x);
			st.insert(x);
		}
		if(on.find(y)!=on.end()){
			on.erase(y);
			st.insert(y);
		}
	}
	ll node=*(st.begin());
	vi vec;
	vec.pb(*st.begin());
	for(int i=2;i<=n;i+=4){
		if(i+1!=*st.begin()&&i-1!=*st.begin())
		vec.pb(i);
	}
	// for(auto i:vec)cout<<i<<" ";
	// 	cout<<endl;
	if(vec.size()<4||n<=10)
		cout<<0<<endl;
	else{
		cout<<vec.size()<<" ";
		for(auto i:vec)cout<<i<<" ";
			cout<<endl;
		cin>>x;
		cout<<0<<endl;
	}

}


#include<bits/stdc++.h>
#include <iomanip>
#include <random>
#include <cassert>
#define ll long long int
#define ld long double
#define f first
#define inf 100000000000000000
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define s second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define Sort(a) sort(a.begin(),a.end());
using namespace std;
ll const mod=998244353;
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
int rand_rng(int l, int r) {
	uniform_int_distribution<int> p(l, r);
	return p(rng);
}
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set os.find_by_order os.order_of_key
// b/w l and r os.order_of_key(r+1)-order_of_key(l)

int arr1[100009];
int parent[100009];
vector<ll> sieve;
void sievefun(ll n){
    for(ll i=2;i<=n;i++){
        if(arr1[i]==0){
              parent[i]=i;
            for(ll j=i*i;j<=n;j+=i){
           		if(arr1[j]==0)parent[j]=i;
                arr1[j]=1;
            }
        }
    }
    // for(int i=2;i<=n;i++){
    // 	if(arr1[i]==0)sieve.pb(i);
    // }
}
ll power(ll x, ll y,ll m) {
	ll temp;
	if( y == 0||x==1)
		return 1;
	temp = power(x, y/2,m)%m;
	if (y%2 == 0)
		return ((temp)*(temp))%m;
	else
		return (((x)%m)*((temp*temp)%m))%m;
}

// ll fac[1000009];
// void factorial(){
// 	fac[0]=1;
// 	for(int i=1;i<=1000000;i++)fac[i]=(i*fac[i-1])%mod;
// }
// ll ncr(ll n,ll r){
// 	return (fac[n]*((power(fac[r],mod-2)*power(fac[n-r],mod-2))%mod))%mod;
// }
int const N=200009;

int main()
{	//sievefun(20000);
	// ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,x,y;
	cin>>n;
	set<ll> st,on,off;
	int ind=1;
	if(n<=3){
		cout<<0<<endl;
		return 0;
	}
	ll num=0;
	ind=0;
	for(int i=1;i<=n;i++){
		// cout<<n-i+1-((n+i-1)/i)<<"\n";
		if(n-i+1-((n+i-1)/i)>num){
			num=n-i+1-((n+i-1)/i);
			ind=i;
		}
	}
	// cout<<ind<<"\n";
	for(int i=1;i<=n;i++){
		if((i-1)%(ind)==0)continue;
		off.insert(i);
	}

	while(off.size()>=ind){
		vi out;
		forn(i,ind){
			out.pb(*(off.begin()));
			on.insert(*(off.begin()));
			off.erase(*(off.begin()));
		}
		cout<<out.size()<<" ";
		for(auto i:out)cout<<i<<" ";
			cout<<endl;
		cin>>x;
		forn(i,ind){
			if(on.find(x)!=on.end()){
				on.erase(x);
				off.insert(x);
			}
			x++;
			if(x>n)x-=n;
		}
	}
	cout<<0<<endl;

}


#include<bits/stdc++.h>
#include <iomanip>
#include <random>
#include <cassert>
#define ll long long int
#define ld long double
#define f first
#define inf 100000000000000000
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define s second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define Sort(a) sort(a.begin(),a.end());
using namespace std;
ll const mod=998244353;
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
int rand_rng(int l, int r) {
	uniform_int_distribution<int> p(l, r);
	return p(rng);
}
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set os.find_by_order os.order_of_key
// b/w l and r os.order_of_key(r+1)-order_of_key(l)

int arr1[100009];
int parent[100009];
vector<ll> sieve;
void sievefun(ll n){
    for(ll i=2;i<=n;i++){
        if(arr1[i]==0){
              parent[i]=i;
            for(ll j=i*i;j<=n;j+=i){
           		if(arr1[j]==0)parent[j]=i;
                arr1[j]=1;
            }
        }
    }
    // for(int i=2;i<=n;i++){
    // 	if(arr1[i]==0)sieve.pb(i);
    // }
}
ll power(ll x, ll y,ll m) {
	ll temp;
	if( y == 0||x==1)
		return 1;
	temp = power(x, y/2,m)%m;
	if (y%2 == 0)
		return ((temp)*(temp))%m;
	else
		return (((x)%m)*((temp*temp)%m))%m;
}

// ll fac[1000009];
// void factorial(){
// 	fac[0]=1;
// 	for(int i=1;i<=1000000;i++)fac[i]=(i*fac[i-1])%mod;
// }
// ll ncr(ll n,ll r){
// 	return (fac[n]*((power(fac[r],mod-2)*power(fac[n-r],mod-2))%mod))%mod;
// }
int const N=200009;

int main()
{	//sievefun(20000);
	// ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,x,y;
	cin>>n;
	set<ll> st,on,off;
	int ind=1;
	if(n<=3){
		cout<<0<<endl;
		return 0;
	}
	ll num=0;
	ind=0;
	for(int i=1;i<=n;i++){
		if(n-(n/i)-i+1>num){
			num=n-(n/i)-i+1;
			ind=i;
		}
	}
	// cout<<ind<<"\n";
	for(int i=1;i<=n;i++){
		if((i-1)%(ind)==0)continue;
		off.insert(i);
	}

	while(off.size()>=ind){
		vi out;
		forn(i,ind){
			out.pb(*(off.begin()));
			on.insert(*(off.begin()));
			off.erase(*(off.begin()));
		}
		cout<<out.size()<<" ";
		for(auto i:out)cout<<i<<" ";
			cout<<endl;
		cin>>x;
		forn(i,ind){
			if(on.find(x)!=on.end()){
				on.erase(x);
				off.insert(x);
			}
			x++;
			if(x>n)x-=n;
		}
	}
	cout<<0<<endl;

}


#include<bits/stdc++.h>
#include <iomanip>
#include <random>
#include <cassert>
#define ll long long int
#define ld long double
#define f first
#define inf 100000000000000000
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define s second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define Sort(a) sort(a.begin(),a.end());
using namespace std;
ll const mod=998244353;
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
int rand_rng(int l, int r) {
	uniform_int_distribution<int> p(l, r);
	return p(rng);
}
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set os.find_by_order os.order_of_key
// b/w l and r os.order_of_key(r+1)-order_of_key(l)

int arr1[100009];
int parent[100009];
vector<ll> sieve;
void sievefun(ll n){
    for(ll i=2;i<=n;i++){
        if(arr1[i]==0){
              parent[i]=i;
            for(ll j=i*i;j<=n;j+=i){
           		if(arr1[j]==0)parent[j]=i;
                arr1[j]=1;
            }
        }
    }
    // for(int i=2;i<=n;i++){
    // 	if(arr1[i]==0)sieve.pb(i);
    // }
}
ll power(ll x, ll y,ll m) {
	ll temp;
	if( y == 0||x==1)
		return 1;
	temp = power(x, y/2,m)%m;
	if (y%2 == 0)
		return ((temp)*(temp))%m;
	else
		return (((x)%m)*((temp*temp)%m))%m;
}

// ll fac[1000009];
// void factorial(){
// 	fac[0]=1;
// 	for(int i=1;i<=1000000;i++)fac[i]=(i*fac[i-1])%mod;
// }
// ll ncr(ll n,ll r){
// 	return (fac[n]*((power(fac[r],mod-2)*power(fac[n-r],mod-2))%mod))%mod;
// }
int const N=200009;

int main()
{	//sievefun(20000);
	// ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,x,y;
	cin>>n;
	set<ll> st,on,off;
	int ind=1;
	if(n<=3){
		cout<<0<<endl;
		return 0;
	}
	while(ind<=n-1){
		st.insert(ind);
		on.insert(ind);
		off.insert(ind);
		ind+=2;
	}
	while(st.size()>1){
		ll node=*(st.begin());
		st.erase(st.begin());
		ll node2=*(st.begin());
		st.erase(st.begin());
		cout<<"2 "<<node<<" "<<node2<<endl;
		on.insert(node);
		on.insert(node2);
		cin>>x;
		if(x==-1)return 0;
		y=x+1;
		if(x==n)y=1;
		if(on.find(x)!=on.end()){
			on.erase(x);
			st.insert(x);
		}
		if(on.find(y)!=on.end()){
			on.erase(y);
			st.insert(y);
		}
	}
	ll node=*(st.begin());
	vi vec;
	vec.pb(*st.begin());
	for(int i=2;i<n;i+=4){
		vec.pb(i);
	}
	// for(auto i:vec)cout<<i<<" ";
	// 	cout<<endl;
	if(vec.size()<4||n<=10)
		cout<<0<<endl;
	else{
		cout<<vec.size()<<" ";
		for(auto i:vec)cout<<i<<" ";
			cout<<endl;
		cin>>x;
		cout<<0<<endl;
	}

}


#include <bits/stdc++.h>

using namespace std;

typedef long long lint;

int read() {
	int x;
	cin >> x;
	return x;
}

int a[1005];

int main() {

	int n;
	cin >> n;

	int pos = 0;

	if (n < 4) {
		cout << "0\n";
		cout.flush();
		return 0;
	}

	while (true) {

		cout << "2\n";
		vector<int> idxs;

		int i;
		for (i = 0; i<n; i+=2) {
			if (a[(pos+i)%n] == 0) {
				a[(pos+i)%n] = 1;
				idxs.push_back((pos+i)%n);
				if (idxs.size() == 2) {
					i += 2;
					break;
				}
			}
		}

		pos = (pos+i) % n;

		cout << "2 " << idxs[0]+1 << " " << idxs[1]+1 << endl;
		cout.flush();

		int x = read();
		if (x == -1) break;

		a[x-1] = a[x%n] = 0;

		int sum = 0;
		for (int i = 0; i<n; i++) sum += a[i];
		if (sum == n/2-1) {
			cout << "0\n";
			cout.flush();
			break;
		}
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long lint;

int read() {
	int x;
	cin >> x;
	return x;
}

int main() {

	int n;
	cin >> n;

	if (n < 4) {
		cout << "0\n";
		cout.flush();
		return 0;
	}

	int mk = 1, m = INT_MIN;
	for (int k = 1; k<=n; k++) {
		//cout << k << " " << n-k-ceil((double)n/k) << endl;
		if (n-k-ceil((double)n/k) > m) {
			m = n-k-ceil((double)n/k);
			mk = k;
		}
	}

	//cout << mk << " " << m << "*\n";

	int a[n];
	for (int i = 0; i<n; i++) {
		if (i % mk == mk-1) a[i] = -1;
		else a[i] = 0;
	}

	while (true) {

		int cnt = 0;
		vector<int> idxs;
		for (int i = 0; i<n && cnt < mk; i++) {
			if (a[i] == 0) {
				cnt++;
				a[i] = 1;
				idxs.push_back(i);
			}
		}

		cout << cnt << " ";
		for (int x : idxs) cout << x+1 << " ";
		cout << endl;
		cout.flush();

		int x = read();
		if (x == -1) return 0;
		x -= 1;
		for (int i = 0; i<mk; i++) {
			if (a[(i+x)%n] != -1) a[(i+x)%n] = 0;
		}

		if (cnt < mk) {
			cout << "0\n";
			cout.flush();
			break;
		}

	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long lint;

int read() {
	int x;
	cin >> x;
	return x;
}

int main() {

	int n;
	cin >> n;

	if (n < 4) {
		cout << "0\n";
		cout.flush();
		return 0;
	}

	int mk = 1, m = 0;
	for (int k = 1; k<=n; k++) {
		if (n-k-ceil(n/k) > m) {
			m = n-k-ceil(n/k);
			mk = k;
		}
	}

	int a[n];
	for (int i = 0; i<n; i++) {
		if (i % mk == mk-1) a[i] = -1;
		else a[i] = 0;
	}

	while (true) {

		int cnt = 0;
		vector<int> idxs;
		for (int i = 0; i<n && cnt < mk; i++) {
			if (a[i] == 0) {
				cnt++;
				a[i] = 1;
				idxs.push_back(i);
			}
		}

		cout << cnt << " ";
		for (int x : idxs) cout << x+1 << " ";
		cout << endl;
		cout.flush();

		int x = read();
		if (x == -1) return 0;
		x -= 1;
		for (int i = 0; i<mk; i++) {
			if (a[(i+x)%n] != -1) a[(i+x)%n] = 0;
		}

		if (cnt < mk) {
			cout << "0\n";
			cout.flush();
			break;
		}

	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long lint;

int read() {
	int x;
	cin >> x;
	return x;
}

int main() {

	int n;
	cin >> n;

	if (n < 4) {
		cout << "0\n";
		cout.flush();
		return 0;
	}

	int mk = 1, m = INT_MIN;
	for (int k = 1; k<=n; k++) {
		//cout << k << " " << n-k-ceil((double)n/k) << endl;
		if (n-k-ceil((double)n/k) > m) {
			m = n-k-ceil((double)n/k);
			mk = k;
		}
	}

	//cout << mk << " " << m << "*\n";

	int a[n];
	for (int i = 0; i<n; i++) {
		if (i % mk == 0) a[i] = -1;
		else a[i] = 0;
	}

	while (true) {

		int cnt = 0;
		vector<int> idxs;
		for (int i = 0; i<n && cnt < mk; i++) {
			if (a[i] == 0) {
				cnt++;
				a[i] = 1;
				idxs.push_back(i);
			}
		}

		cout << cnt << " ";
		for (int x : idxs) cout << x+1 << " ";
		cout << endl;
		cout.flush();

		int x = read();
		if (x == -1) return 0;
		x -= 1;
		for (int i = 0; i<mk; i++) {
			if (a[(i+x)%n] != -1) a[(i+x)%n] = 0;
		}

		if (cnt < mk) {
			cout << "0\n";
			cout.flush();
			break;
		}

	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long lint;

int read() {
	int x;
	cin >> x;
	return x;
}

int a[1005];

int main() {

	int n;
	cin >> n;

	int pos = 0;

	if (n < 4) {
		cout << "0\n";
		cout.flush();
		return 0;
	}

	while (true) {

		vector<int> idxs;

		int i;
		for (i = 0; i<n; i+=2) {
			if (a[(pos+i)%n] == 0) {
				a[(pos+i)%n] = 1;
				idxs.push_back((pos+i)%n);
				if (idxs.size() == 2) {
					i += 2;
					break;
				}
			}
		}

		pos = (pos+i) % n;

		cout << "2 " << idxs[0]+1 << " " << idxs[1]+1 << endl;
		cout.flush();

		int x = read();
		if (x == -1) break;

		a[x-1] = a[x%n] = 0;

		int sum = 0;
		for (int i = 0; i<n; i++) sum += a[i];
		if (sum == n/2-1) {
			cout << "0\n";
			cout.flush();
			break;
		}
	}

	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = 1;
    int target = -100;
    for(int i = 1;i <= n;i++) {
        if((n - ((n+i-1)/i + i) + 1) > target) {
            k = i;
            target = n - ((n+k-1)/k + k) + 1;
        }
    }
    vi arr(n,0);
    int loop = 0;
    while(1) {
        loop++;
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target || ans[0] != k) {deb1(0);break;}
        out_arr(ans,ans.size());
        int x;
        cin>>x;
        if(x == -1) break;
        for1(i,ans[0]) {
            arr[ans[i]-1] = 1;
        }
        for(int i = x-1;i < x+ans[0]-1;i++) {
            arr[i] = 0;
        }
        assert(loop <= 1000);
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = 1;
    int target = -100;
    for(int i = 1;i <= n;i++) {
        if((n - ((n-1)/i + i)) > target) {
            k = i;
            target = n - ((n-1)/k + k);
        }
    }
    vi arr(n,0);
    int loop = 0;
    while(1) {
        loop++;
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target || ans[0] != k) {deb1(0);break;}
        out_arr(ans,ans.size());
        int x;
        cin>>x;
        //if(x == -1) break;
        for1(i,ans[0]) {
            arr[ans[i]-1] = 1;
        }
        for(int i = x-1;i < x+ans[0]-1;i++) {
            arr[i] = 0;
        }
        assert(loop <= 1000);
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = sqrtl(n-1);
    double a1 = ((n-1)/(double)k) + (double)k,a2 = ((n-1)/(double)(k+1)) + (double)k + 1.0;
    if(a2 < a1) {
        k++;
    }
    int target = n - (((n-1)/k) + k);
    vi arr(n,0);
    while(1) {
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target) {deb1(0);break;}
        out_arr(ans,ans.size());
        int x;
        cin>>x;
        if(x == -1) break;
        for1(i,ans[0]) {
            arr[i] = 1;
        }
        for(int i = x-1;i < x+ans[0]-1;i++) {
            arr[i] = 0;
        }
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = sqrtl(n-1);
    double a1 = ((n-1)/(double)k) + (double)k,a2 = ((n-1)/(double)(k+1)) + (double)k + 1.0;
    if(a2 < a1) {
        k++;
    }
    int target = n - (((n-1)/k) + k);
    vi arr(n,0);
    while(1) {
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target || !ans[0]) {deb1(0);break;}
        out_arr(ans,ans.size());
        int x;
        cin>>x;
        if(x == -1) break;
        for1(i,ans[0]) {
            arr[ans[i]-1] = 1;
        }
        for(int i = x-1;i < x+ans[0]-1;i++) {
            arr[i] = 0;
        }
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = 1;
    int target = -100;
    for(int i = 1;i <= n;i++) {
        if((n - ((n-1)/i + i)) > target) {
            k = i;
            target = n - ((n-1)/k + k);
        }
    }
    vi arr(n,0);
    int loop = 0;
    while(1) {
        loop++;
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target || ans[0] != k) {deb1(0);break;}
        out_arr(ans,ans.size());
        int x;
        cin>>x;
        if(x == -1) break;
        for1(i,ans[0]) {
            arr[ans[i]-1] = 1;
        }
        for(int i = x-1,tt = 0;tt < ans[0];tt++,i = (i+1)%n) {
            arr[i] = 0;
        }
        assert(loop <= 1000);
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = sqrtl(n-1);
    double a1 = ((n-1)/(double)k) + (double)k,a2 = ((n-1)/(double)(k+1)) + (double)k + 1.0;
    if(a2 < a1) {
        k++;
    }
    int target = n - (((n-1)/k) + k);
    vi arr(n,0);
    while(1) {
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target) {deb1(0);break;}
        out_arr(ans,ans.size());
        int x;
        cin>>x;
        if(x == -1) break;
        for1(i,ans[0]) {
            arr[ans[i]-1] = 1;
        }
        for(int i = x-1;i < x+ans[0]-1;i++) {
            arr[i] = 0;
        }
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = 1;
    int target = -100;
    for(int i = 1;i <= n;i++) {
        if((n - ((n-1)/i + i)) > target) {
            k = i;
            target = n - ((n-1)/k + k);
        }
    }
    vi arr(n,0);
    int loop = 0;
    while(1) {
        loop++;
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target || ans[0] != k) {deb1(0);break;}
        out_arr(ans,ans.size());
        int x;
        cin>>x;
        if(x == -1) break;
        for1(i,ans[0]) {
            arr[ans[i]-1] = 1;
        }
        for(int i = x-1;i < x+ans[0]-1;i++) {
            arr[i] = 0;
        }
        assert(loop <= 1000);
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = sqrtl(n-1);
    int a1 = ((n-1)/k) + k,a2 = ((n-1)/(k+1)) + k + 1;
    if(a2 < a1) {
        k++;
    }
    int target = n - (((n-1)/k) + k);
    vi arr(n,0);
    while(1) {
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target || !ans[0] || ans[0] != k) {deb1(0);break;}
        out_arr(ans,ans.size());
        int x;
        cin>>x;
        if(x == -1) break;
        for1(i,ans[0]) {
            arr[ans[i]-1] = 1;
        }
        for(int i = x-1;i < x+ans[0]-1;i++) {
            arr[i] = 0;
        }
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = sqrtl(n-1);
    double a1 = ((n-1)/(double)k) + (double)k,a2 = ((n-1)/(double)(k+1)) + (double)k + 1.0;
    if(a2 < a1) {
        k++;
    }
    int target = n - (((n-1)/k) + k);
    vi arr(n,0);
    while(1) {
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target) {deb1(0);break;}
        out_arr(arr,arr.size());
        int x;
        cin>>x;
        if(x == -1) break;
        for(int i = x-1;i < x+k;i++) {
            ans[i] = 0;
        }
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = sqrtl(n-1);
    double a1 = ((n-1)/(double)k) + (double)k,a2 = ((n-1)/(double)(k+1)) + (double)k + 1.0;
    if(a2 < a1) {
        k++;
    }
    int target = n - (((n-1)/k) + k);
    vi arr(n,0);
    int loop = 0;
    while(1) {
        loop++;
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target || ans[0] != k) {deb1(0);break;}
        out_arr(ans,ans.size());
        int x;
        cin>>x;
        if(x == -1) break;
        for1(i,ans[0]) {
            arr[ans[i]-1] = 1;
        }
        for(int i = x-1,tt = 0;tt < ans[0];tt++,i = (i+1)%n) {
            arr[i] = 0;
        }
        assert(loop <= 1000);
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define F first
#define S second
#define EPS 1e-12
#define all(x) (x).begin(),(x).end()
#define INF ll(2e18)
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<ll,ll> > vll;
typedef long double LD;

const ll mod =  998244353;

/*
ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll phi(ll n) {
    ll tot = n;
    for(ll i = 2;i*i <= n;i++) {
        if(n%i == 0) {
            tot -= tot/i;
        }
        while(n%i == 0) {
            n /= i;
        }
    }
    if(n > 1) {
        tot -= tot/n;
    }
    return tot;
}
*/

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}
/*
void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
 */
ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n <= 3) {
        deb1(0);
        return;
    }
    int k = sqrtl(n-1);
    double a1 = ((n-1)/(double)k) + (double)k,a2 = ((n-1)/(double)(k+1)) + (double)k + 1.0;
    if(a2 < a1) {
        k++;
    }
    int target = n - (((n-1)/k) + k);
    vi arr(n,0);
    while(1) {
        vi ans(1,0);
        int cnt = 0;
        for0(i,n-1) {
            if((i%k) != (k-1) && !arr[i] && ans[0] < k) {
                ans[0]++;
                ans.PB(i+1);
            }
            if(arr[i]) cnt++;
        }
        if(cnt >= target) {deb1(0);break;}
        out_arr(ans,ans.size());
        int x;
        cin>>x;
        if(x == -1) break;
        for(int i = x-1;i < x+ans[0];i++) {
            arr[i] = 0;
        }
    }
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[1005];
int n;
queue<int> q;
int ret;
void mv(){
    if (q.size() <= 1){
        cout << 0 << endl;
        for (int i = 1; i <= n; i++){
            printf("%d ",a[i]);
        }
        exit(0);
    }
    else{
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        cout << "2 " << x << " " << y << endl;
        a[x] = a[y] = 1;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        if (a[ret]){
            a[ret] = 0;
            q.push(ret);
        }
        if (a[ret%n+1]){
            a[ret%n+1] = 0;
            q.push(ret%n+1);
        }
    }
}
int main(){
    cin >> n;
    if (n <= 3){
        printf("0");
        return 0;
    }
    for (int i = 1; i <= n; i+=2){
        q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[1005];
int n;
int k = 2;
queue<int> q;
int ret;
void mv(){
    if (q.size() < k){
        cout << "0" << endl;
        exit(0);
    }
    else{
        int N = q.size();
        cout << N << " ";
        while (q.size()) {cout << q.front() << " "; a[q.front()] = 1; q.pop();}
        cout << endl;
        //ret = y;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        for (int i = 0; i < N; i++){
            int X = (i+ret-1)%n+1;
            if (a[X]){
                a[X] = 0;
                q.push(X);
            }
        }
    }
    //printf("\n");
}
int main(){
    cin >> n;
    if (n <= 3){
       cout << "0" << endl;
       exit(0);
    }

    for (int i = 2; i <= n; i++){
        if ((n/(i-1)) * (i-1) > (n/(k-1)) * (k-1)) k = i;
    }
    printf("found %d\n",k);
    for (int i = 1; i <= n; i++){
        if ((i%k) != 0 && i != n) q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[1005];
int n;
queue<int> q;
int ret;
void mv(){
    if (q.size() <= 1){
        cout << 0 << endl;
        for (int i = 1; i <= n; i++){
            printf("%d ",a[i]);
        }
        exit(0);
    }
    else{
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        cout << "2 " << x << " " << y << endl;
        a[x] = a[y] = 1;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        if (a[ret]){
            a[ret] = 0;
            q.push(ret);
        }
        if (a[ret%n+1]){
            a[ret%n+1] = 0;
            q.push(ret%n+1);
        }
    }
}
int main(){
    cin >> n;
    for (int i = 1; i <= n; i+=2){
        q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[20005];
int n;
queue<int> q;
int ret;
void mv(){
    int CT = 0;
    for (int i = 1; i <= n; i++){
        CT += a[i];
    }
    if (CT == n/2-1){
        cout << "0" << endl;
        exit(0);
    }
    if (q.size() <= 1){
        while (true){
            CT++;
        }
    }
    else{
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        cout << "2 " << x << " " << y << endl;
        a[x] = a[y] = 1;
        //ret = y;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        if (a[ret]){
            a[ret] = 0;
            q.push(ret);
        }
        if (a[ret%n+1]){
            a[ret%n+1] = 0;
            q.push(ret%n+1);
        }
    }
    //printf("\n");
}
int main(){
    cin >> n;
    if (n <= 3){
       cout << "0" << endl;
       exit(0);
    }
    for (int i = 1; i <= n-1; i+=2){
        q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[20005];
int n;
queue<int> q;
int ret;
//int ct = 0;
void mv(){
    //ct++;
    for (int i = 1; i <= n; i++){
        //printf("%d ",a[i]);
        CT += a[i];
    }
    if (CT == n/2-1){
        cout << "0" << endl;
        exit(0);
    }
    if (q.size() <= 1){
        while (true){
            CT++;
        }
    }
    else{
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        cout << "2 " << x << " " << y << endl;
        a[x] = a[y] = 1;
        //ret = y;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        if (a[ret]){
            a[ret] = 0;
            q.push(ret);
        }
        if (a[ret%n+1]){
            a[ret%n+1] = 0;
            q.push(ret%n+1);
        }
    }
    //printf("\n");
}
int main(){
    cin >> n;
    if (n <= 3){
       cout << "0" << endl;
       exit(0);
    }
    for (int i = 1; i <= n-1; i+=2){
        q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[1005];
int n;
int k = 2;
queue<int> q;
int ret;
void mv(){
    if (q.size() <= k){
        cout << "0" << endl;
        exit(0);
    }
    else{
        int N = q.size();
        cout << N << " ";
        while (q.size()) {cout << q.front() << " "; a[q.front()] = 1; q.pop();}
        cout << endl;
        //ret = y;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        for (int i = 0; i < N; i++){
            int X = (i+ret-1)%n+1;
            if (a[X]){
                a[X] = 0;
                q.push(X);
            }
        }
    }
    //printf("\n");
}
int main(){
    cin >> n;
    if (n <= 3){
       cout << "0" << endl;
       exit(0);
    }

    for (int i = 2; i <= n; i++){
        if ((n/(i-1)) * (i-1) > (n/(k-1)) * (k-1)) k = i;
    }
    //printf("found %d\n",k);
    for (int i = 1; i <= n; i++){
        if ((i%k) != 0 && i != n) q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[20005];
int n;
queue<int> q;
int ret;
//int ct = 0;
void mv(){
    //ct++;
    if (q.size() <= 1){
        //printf("%d ",ct);
        int CT = 0;
        for (int i = 1; i <= n; i++){
            //printf("%d ",a[i]);
            CT += a[i];
        }
        if (CT != n/2-1){
            while (true){
                CT++;
            }
        }
        //printf("%d\n",CT);
        cout << "0" << endl;

        exit(0);
    }
    else{
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        cout << "2 " << x << " " << y << endl;
        a[x] = a[y] = 1;
        //ret = y;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        if (a[ret]){
            a[ret] = 0;
            q.push(ret);
        }
        if (a[ret%n+1]){
            a[ret%n+1] = 0;
            q.push(ret%n+1);
        }
    }

    //printf("\n");
}
int main(){
    cin >> n;
    if (n <= 3){
       cout << "0" << endl;
       exit(0);
    }
    for (int i = 1; i <= n-1; i+=2){
        q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[1005];
int n;
queue<int> q;
int ret;
void mv(){
    if (q.size() <= 1){
        cout << "0" << endl;
        /*for (int i = 1; i <= n; i++){
            printf("%d ",a[i]);
        }*/
        exit(0);
    }
    else{
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        cout << "2 " << x << " " << y << endl;
        a[x] = a[y] = 1;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        if (a[ret]){
            a[ret] = 0;
            q.push(ret);
        }
        if (a[ret%n+1]){
            a[ret%n+1] = 0;
            q.push(ret%n+1);
        }
    }
}
int main(){
    cin >> n;
    if (n <= 3){
       cout << "0" << endl;
        return 0;
    }
    for (int i = 1; i <= n-1; i+=2){
        q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[1005];
int n;
int k = 2;
queue<int> q;
int ret;
void mv(){
    if (q.size() < k){
        cout << "0" << endl;
        exit(0);
    }
    else{
        int N = q.size();
        cout << N << " ";
        while (q.size()) {cout << q.front() << " "; a[q.front()] = 1; q.pop();}
        cout << endl;
        //ret = y;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        for (int i = 0; i < N; i++){
            int X = (i+ret-1)%n+1;
            if (a[X]){
                a[X] = 0;
                q.push(X);
            }
        }
    }
    //printf("\n");
}
int main(){
    cin >> n;
    if (n <= 3){
       cout << "0" << endl;
       exit(0);
    }

    for (int i = 2; i <= n; i++){
        if ((n/(i-1)) * (i-1) > (n/(k-1)) * (k-1)) k = i;
    }
    //printf("found %d\n",k);
    for (int i = 1; i <= n; i++){
        if ((i%k) != 0 && i != n) q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[1005];
int n;
int k;
int B;
queue<int> q;
int ret;
void mv(){
    if (q.size() < k){
        /*for (int i = 1; i <= n; i++){
            printf("%d ",a[i]);
        }
        printf("\n");*/
        cout << "0" << endl;
        exit(0);
    }
    else{
        int N = q.size();
        cout << N << " ";
        while (q.size()) {cout << q.front() << " "; a[q.front()] = 1; q.pop();}
        cout << endl;
        //ret = y;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        for (int i = 0; i < N; i++){
            int X = (i+ret-1)%n+1;
            if (a[X]){
                a[X] = 0;
                q.push(X);
            }
        }
    }
    //printf("\n");
}
int main(){
    cin >> n;
    if (n <= 3){
       cout << "0" << endl;
       exit(0);
    }

    for (int i = 2; i*i <= n; i++){
        int ct = 0;
        for (int j = 1; j <= n; j++){
            if ((j%i) != 0 && j != n) ct++;
        }
        if (k == 0 || ct > B){
            k = i;
            B = ct;
        }
    }
    //printf("found %d %d\n",k,B);
    for (int i = 1; i <= n; i++){
        if ((i%k) != 0 && i != n) q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[1005];
int n;
queue<int> q;
int ret;
void mv(){
    if (q.size() <= 1){
        cout << 0 << endl;
        /*for (int i = 1; i <= n; i++){
            printf("%d ",a[i]);
        }*/
        exit(0);
    }
    else{
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        cout << "2 " << x << " " << y << endl;
        a[x] = a[y] = 1;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        if (a[ret]){
            a[ret] = 0;
            q.push(ret);
        }
        if (a[ret%n+1]){
            a[ret%n+1] = 0;
            q.push(ret%n+1);
        }
    }
}
int main(){
    cin >> n;
    if (n <= 3){
       cout << 0 << endl;
        return 0;
    }
    for (int i = 1; i <= n; i+=2){
        q.push(i);
    }
    while (true){
        mv();
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[20005];
int n;
queue<int> q;
int ret;
//int ct = 0;
void mv(){
    //ct++;
    if (q.size() <= 1){
        //printf("%d ",ct);
        int CT = 0;
        for (int i = 1; i <= n; i++){
            //printf("%d ",a[i]);
            CT += a[i];
        }
        assert(CT == n/2-1);
        //printf("%d\n",CT);
        cout << "0" << endl;

        exit(0);
    }
    else{
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        cout << "2 " << x << " " << y << endl;
        a[x] = a[y] = 1;
        //ret = y;
        cin >> ret;
        if (ret == -1){
            exit(0);
        }
        if (a[ret]){
            a[ret] = 0;
            q.push(ret);
        }
        if (a[ret%n+1]){
            a[ret%n+1] = 0;
            q.push(ret%n+1);
        }
    }

    //printf("\n");
}
int main(){
    cin >> n;
    if (n <= 3){
       cout << "0" << endl;
        return 0;
    }
    for (int i = 1; i <= n-1; i+=2){
        q.push(i);
    }
    while (true){
        mv();
    }
}


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

using namespace std;
const int MAXN = 1e6+5;
stack<int> can;
bool hold[MAXN];
int main(){
    int n;
    cin>>n;
    if(n<=3){
        cout<<0<<endl;
        return 0;
    }
    int a= 1;
    int b = 1;
    while(a*b<=n){
        a++;
        if(a>b){
            swap(a,b);
        }
    }
    for(int i=0;i<n;i++){
        if(i%b!=0){
            can.push(i);
        }
    }
    while(can.size()>=b){
        cout<<b;
        for(int i=0;i<b;i++){
            int hold = can.top();
            cout<<" "<<hold+1;
            hold[y] = true;
            can.pop();
        }
        cout<<endl;
        int x;
        cin>>x;
        for(int i=0;i<b;i++){
            int y = (x-1+i)%n;
            if(hold[y]){
                hold[y] = false;
                can.push(y);
            }
        }
    }
    cout<<endl;

}


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

using namespace std;
const int MAXN = 1e6+5;
stack<int> can;
bool hold[MAXN];
int main(){
    int n;
    cin>>n;
    if(n<=3){
        cout<<0<<endl;
        return 0;
    }
    int a= 1;
    int b = 1;
    while(a*b<n){
        a++;
        if(a>b){
            swap(a,b);
        }
    }
    for(int i=0;i<n;i++){
        if(i%b!=0){
            can.push(i);
        }
    }
    while(can.size()>=b){
        cout<<b;
        for(int i=0;i<b;i++){
            int y = can.top();
            cout<<" "<<y+1;
            hold[y] = true;
            can.pop();
        }
        cout<<endl;
        int x;
        cin>>x;
        for(int i=0;i<b;i++){
            int y = (x-1+i)%n;
            if(hold[y]){
                hold[y] = false;
                can.push(y);
            }
        }
    }
    cout<<endl;

}


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

using namespace std;
const int MAXN = 1e6+5;
stack<int> can;
bool hold[MAXN];
int main(){
    int n;
    cin>>n;
    if(n<=3){
        cout<<0<<endl;
        return 0;
    }
    int a= 1;
    int b = 1;
    while(a*b<n){
        a++;
        if(a>b){
            swap(a,b);
        }
    }

    for(int i=0;i<n;i++){
        if(i%b!=0){
            can.push(i);
        }
    }
    while((int)can.size()>=b){
        cout<<b;
        for(int i=0;i<b;i++){
            int y = can.top();
            cout<<" "<<y+1;
            hold[y] = true;
            can.pop();
        }
        cout<<endl;
        cout.flush();
        int x;
        cin>>x;
        for(int i=0;i<b;i++){
            int y = (x-1+i)%n;

            if(hold[y]){
                hold[y] = false;
                can.push(y);
            }
        }
    }
    cout<<0<<endl;

}


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

using namespace std;
const int MAXN = 1e6+5;
stack<int> can;
bool hold[MAXN];
int main(){
    int n;
    cin>>n;
    if(n<=3){
        cout<<0<<endl;
        return 0;
    }
    int a= 1;
    int b = 1;
    while(a*b<=n){
        a++;
        if(a>b){
            swap(a,b);
        }
    }
    for(int i=0;i<n;i++){
        if(i%b!=0){
            can.push(i);
        }
    }
    while(can.size()>=b){
        cout<<b;
        for(int i=0;i<b;i++){
            int y = can.top();
            cout<<" "<<y+1;
            hold[y] = true;
            can.pop();
        }
        cout<<endl;
        int x;
        cin>>x;
        for(int i=0;i<b;i++){
            int y = (x-1+i)%n;
            if(hold[y]){
                hold[y] = false;
                can.push(y);
            }
        }
    }
    cout<<endl;

}


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

using namespace std;
const int MAXN = 1e6+5;
stack<int> can;
bool hold[MAXN];
int main(){
    int n;
    cin>>n;
    if(n<=3){
        cout<<0<<endl;
        return 0;
    }
    int a= 1;
    int b = 1;
    while(a*b<n){
        a++;
        if(a>b){
            swap(a,b);
        }
    }

    for(int i=0;i<n;i++){
        if(i%b!=0){
            can.push(i);
        }
    }
    while((int)can.size()>=b){
        cout<<b;
        for(int i=0;i<b;i++){
            int y = can.top();
            cout<<" "<<y+1;
            hold[y] = true;
            can.pop();
        }
        cout<<endl;
        cout.flush();
        int x;
        cin>>x;
        for(int i=0;i<b;i++){
            int y = (x-1+i)%n;

            if(hold[y]){
                hold[y] = false;
                can.push(y);
            }
        }
    }
    cout<<endl;

}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz(x) (ll)x.size()
#define all(x) x.begin(), x.end()
#define forn(x) for(int i=1;i<=x;i++)
#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)
#define pii pair<int, int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK

    PIHALITI

*/

int used[1001];
void solve(){
    int n;
    cin >> n;
    if(n < 4){
        cout << 0 << endl;
        return;
    }
    int cnt = 0;
    for(int i = 1; i <= 10; i++) {
        if((1<<i) > n) break;
        set<int> s;
        for(int j = (1<<i); j <= n; j+=(1<<i)) {
            s.insert(j);
            if(sz(s) == (1<<i)){
                cout << sz(s) << " ";
                for(auto to : s){
                    cout << to << ' ';
                }
                cout << endl;
                s.clear();
                int x;
                cin >> x;
                for(int z = x; z <= x + (1<<i) - 1; z++) {
                    int to = (z - 1) % n + 1;
                    if(to % (1<<i) == 0 && to <= j) {
                        s.insert(to);
                    }
                }
            }
        }
    }
    cout << 0 << endl;
}
int main(){ speed;
    int t;
    // cin >> t;
    for(int i = 1; i <= 1; i++) {
        solve();
    }
    return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz(x) (ll)x.size()
#define all(x) x.begin(), x.end()
#define forn(x) for(int i=1;i<=x;i++)
#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)
#define pii pair<int, int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK

    PIHALITI

*/
void solve(){
    int n;
    cin >> n;
    if(n < 4){
        cout << 0 << endl;
        return;
    }
    int cnt = 0;
    int f = 1;
    for(int i = 3; i <= n; i+=2) {
        cout << 2 << ' ' << f << ' ' << i << endl;
        cnt += 2;
        int x;
        cin >> x;
        if(x%2==0) ++x;
        if(x > n) x = 1;
        if(x <= i) {
            --cnt;
            f = x;
        }
        if(cnt == n/2-1) {
            break;
        }
    }
    cout << 0 << endl;
}
int main(){ speed;
    int t;
    // cin >> t;
    for(int i = 1; i <= 1; i++) {
        solve();
    }
    return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define forn(x) for(int i=1;i<=x;i++)
#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)
#define pii pair<int, int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK

    PIHALITI

*/

// 00000000000000000
// 11101110111011100

int used[200100];
int n;
void check(set<int> s, int x) {
    for(auto to: s){
        used[to] = 1;
    }
    for(int i = x; i < x + sz(s); i++) {
        int p = (i - 1) % n + 1;
        used[p] = 0;
    }
}
void solve(){
    cin >> n;
    int x = sqrt(n);
    set<int> s;
    for(int i = 1; i <= n; i++) {
        if(i % x){
            s.insert(i);
        }
        if(sz(s) == x) {
            cout << x << ' ';
            for(auto to : s){
                cout << to << ' ';
            }
            cout << endl;
            int x2;
            cin >> x2;
            // check(s, x2);
            s.clear();
            for(int j = x2 ; j < x2 + x; j++) {
                int to = (j - 1) % n + 1;
                if(to % x && to <= i){
                    s.insert(to);
                }
            }
        }
    }
    cout << 0 << endl;
}
int main(){ speed;
    int t;
    // cin >> t;
    for(int i = 1; i <= 1; i++) {
        solve();
    }
    return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz(x) (ll)x.size()
#define all(x) x.begin(), x.end()
#define forn(x) for(int i=1;i<=x;i++)
#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)
#define pii pair<int, int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK

    PIHALITI

*/
void solve(){
    int n;
    cin >> n;
    if(n < 4){
        cout << 0 << endl;
        return;
    }
    int cnt = 0;
    int f = 1;
    for(int i = 3; i <= n; i+=2) {
        cout << 2 << ' ' << f << ' ' << i << endl;
        cnt += 2;
        int x;
        cin >> x;
        if(x%2==0) ++x;
        if(x > n) x = 1;
        if(x <= i) {
            --cnt;
            f = x;
        } else if(x == n) {
            --cnt;
            f = 1;
        }
        if(cnt == n/2-1) {
            break;
        }
    }
    cout << 0 << endl;
}
int main(){ speed;
    int t;
    // cin >> t;
    for(int i = 1; i <= 1; i++) {
        solve();
    }
    return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz(x) (ll)x.size()
#define all(x) x.begin(), x.end()
#define forn(x) for(int i=1;i<=x;i++)
#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)
#define pii pair<int, int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK

    PIHALITI

*/

int used[1001];

// 0101010101010100
// 0101010101010101
// 0111011101110000

void solve(){
    int n;
    cin >> n;
    if(n < 4){
        cout << 0 << endl;
        return;
    }
    vector<int> v;
    set<int> s2;
    for(int i = 1; i <=n; i++) {
        v.pb(i);
        s2.insert(i);
    }
    int cnt = 0;
    for(int i = 1; i <= 10; i++) {
        vector<int> v2;
        s2.clear();
        for(int j = 0; j < sz(v); j+=2) {
            v2.pb(v[j]);
            s2.insert(v[j]);
        }
        v = v2;
        if((1<<i) > sz(v)) break;
        set<int> s;
        for(auto j: v) {
            s.insert(j);
            if(sz(s) == (1<<i)){
                cout << sz(s) << " ";
                for(auto to : s){
                    cout << to << ' ';
                }
                cout << endl;
                s.clear();
                int x;
                cin >> x;
                for(int z = x; z <= x + (1<<i) - 1; z++) {
                    int to = (z - 1) % n + 1;
                    if(s2.count(to)) s.insert(to);
                }
            }
        }
    }
    cout << 0 << endl;
}
int main(){ speed;
    int t;
    // cin >> t;
    for(int i = 1; i <= 1; i++) {
        solve();
    }
    return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define forn(x) for(int i=1;i<=x;i++)
#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)
#define pii pair<int, int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK

    PIHALITI

*/

// 00000000000000000
// 11101110111011100

int used[200100];
int n;
void check(set<int> s, int x) {
    for(auto to: s){
        used[to] = 1;
    }
    for(int i = x; i < x + sz(s); i++) {
        int p = (i - 1) % n + 1;
        used[p] = 0;
    }
}
void solve(){
    cin >> n;
    int x = sqrt(n);
    cout << x << endl;
    set<int> s;
    for(int i = 1; i <= n; i++) {
        if(i % x){
            s.insert(i);
        }
        if(sz(s) == x) {
            cout << x << ' ';
            for(auto to : s){
                cout << to << ' ';
            }
            cout << endl;
            int x2;
            cin >> x2;
            // check(s, x2);
            s.clear();
            for(int j = x2 ; j < x2 + x; j++) {
                int to = (j - 1) % n + 1;
                if(to % x && to <= i){
                    s.insert(to);
                }
            }
        }
    }
    cout << 0 << endl;
}
int main(){ speed;
    int t;
    // cin >> t;
    for(int i = 1; i <= 1; i++) {
        solve();
    }
    return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz(x) (ll)x.size()
#define all(x) x.begin(), x.end()
#define forn(x) for(int i=1;i<=x;i++)
#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)
#define pii pair<int, int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK

    PIHALITI

*/

int used[1001];

// 0101010101010100
// 0101010101010101
// 0111011101110000

void solve(){
    int n;
    cin >> n;
    if(n < 4){
        cout << 0 << endl;
        return;
    }
    vector<int> v;
    for(int i = 1; i <=n; i++) {
        v.pb(i);
    }
    int cnt = 0;
    for(int i = 1; i <= 10; i++) {
        vector<int> v2;
        for(int j = 0; j < sz(v); j+=2) {
            v2.pb(v[j]);
        }
        v = v2;
        if((1<<i) > sz(v)) break;
        set<int> s;
        for(auto j: v) {
            s.insert(j);
            if(sz(s) == (1<<i)){
                cout << sz(s) << " ";
                for(auto to : s){
                    cout << to << ' ';
                }
                cout << endl;
                s.clear();
                int x;
                cin >> x;
                for(int z = x; z <= x + (1<<i) - 1; z++) {
                    int to = (z - 1) % n + 1;
                    if(to % (1<<i) == 0 && to <= j) {
                        s.insert(to);
                    }
                }
            }
        }
    }
    cout << 0 << endl;
}
int main(){ speed;
    int t;
    // cin >> t;
    for(int i = 1; i <= 1; i++) {
        solve();
    }
    return 0;
}


#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int inf = 111111111;

struct state{
    long long l, r;
    int mod;
};

state make_state(long long l, long long r, int mod) {
    state ret;
    ret.l = l;
    ret.r = r;
    ret.mod = mod;
    return ret;
}

int n;
map <long long, int> m;
vector<state> v;

int get_ans(long long poz) {
    if (m.count(poz)) {
        return m[poz];
    }
    int l = 0, r = v.size();
    while (r - l > 1) {
        int x = (l + r) / 2;
        if (v[x].l <= poz && poz <= v[x].r) {
            l = x;
            break;
        }
        if (poz < v[x].l) {
            r = x;
        }
        else {
            l = x;
        }
    }
    //cout << "!!!  " << poz << ' ' << l << ' ' << v[l].l << ' ' << v[l].r << "  " << v[l].mod << endl;
    //for (int i = 0; i /3 < inf; ++i);
    if ((poz - v[l].l + 1) % v[l].mod == 0) {
        return get_ans(v[l].mod);
    }
    return get_ans((poz - v[l].l + 1) % v[l].mod);
}

int main() {
    //freopen("output.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    //cin >> n;
    long long len = 0;
    for (int i = 0; i < n; ++i) {
        int t;
        scanf("%d", &t);
        if (t == 1) {
            int x;
            scanf("%d", &x);
            //cin >> x;
            ++len;
            m[len] = x;
        } else {
            long long l, x;
            scanf("%I64d%I64d", &l, &x);
            //cin >> l >> x;
            v.push_back(make_state(len + 1, len + l * x, (int)l));
            len += l * x;
        }
    }
    /*cout << endl;
    for (int i = 0; i < v.size(); ++i) {
        cout << v[i].l << ' ' << v[i].r << endl;
    }
    cout << endl;*/
    //cout << endl << len << endl;
    scanf("%d", &n);
    //cin >> n;
    for (int i = 0; i < n; ++i) {
        long long poz;
        scanf("%I64d", &poz);
        //cin >> poz;
        printf("%d ", get_ans(poz));
        //cout << get_ans(poz) << ' ';
    }
    //cout << endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

#define pb push_back
vector<long long> be, len;
map<long long, int> Map;

int m, n;

int getLast(long long num){
    int lf = 0, rt = be.size() - 1;
    int ans = -1;
    while( lf <= rt ){
        int mid = (lf + rt) >>1;
        if( be[mid] <= num ){
            ans = mid;
            lf = mid + 1;
        }else
            rt = mid - 1;
    }
    return ans;
}
int getNum(long long num ){
    if(Map.find(num) == Map.end() ){
        int id = getLast( num );
        long long rem = (num - be[id])% len[id];
        Map[num] = getNum( rem );
    }
    return Map[num];
}

int main(){
//    freopen("in.txt", "r", stdin );
    cin>>m;
    long long sum = 0;
    for(int i = 0; i < m; ++i){
        int op;
        cin>>op;
        if( op == 1 ){
            int val;
            cin>>val;
            Map[sum++] = val;
        }else{
            long long l, c;
            cin>>l>>c;
            be.pb( sum );   len.pb( l );
            sum += l * c;
        }
    }
    cin>>n;
    for(int i = 0; i < n; ++i){
        long long num;
        cin>>num;
        cout<<getNum( num - 1)<<" ";
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

const int maxn = 100010;
#define pb push_back
vector<long long> be, len;
map<long long, int> Map;

int m, n;

int getLast(long long num){
    int lf = 0, rt = be.size() - 1;
    int ans = -1;
    while( lf <= rt ){
        int mid = (lf + rt) >>1;
        if( be[mid] <= num ){
            ans = mid;
            lf = mid + 1;
        }else
            rt = mid - 1;
    }
    return ans;
}
int getNum(long long num ){
    if(Map.find(num) == Map.end() ){
        int id = getLast( num );
        long long rem = (num - be[id] )% len[id];
        if( rem == 0 ) rem = len[id];
        Map[num] = getNum( rem );
    }
    return Map[num];
}

int main(){
//    freopen("in.txt", "r", stdin );
    cin>>m;
    long long sum = 0;
    for(int i = 0; i < m; ++i){
        int op;
        cin>>op;
        if( op == 1 ){
            int val;
            cin>>val;
            Map[++sum] = val;
        }else{
            long long l, c;
            cin>>l>>c;
            be.pb( sum );   len.pb( l );
            sum += l * c;
        }
    }
    cin>>n;
    for(int i = 0; i < n; ++i){
        long long num;
        cin>>num;
        cout<<getNum( num )<<" ";
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

#define pb push_back
vector<long long> be, len;
map<long long, int> Map;

int m, n;

int getLast(long long num){
    int lf = 0, rt = be.size() - 1;
    int ans = -1;
    while( lf <= rt ){
        int mid = (lf + rt) >>1;
        if( be[mid] <= num ){
            ans = mid;
            lf = mid + 1;
        }else
            rt = mid - 1;
    }
    return ans;
}
int getNum(long long num ){
    if(Map.find(num) == Map.end() ){
        int id = getLast( num );
        long long rem = (num - be[id] )% len[id];
        if( rem == 0 ) rem = len[id];
        Map[num] = getNum( rem );
    }
    return Map[num];
}

int main(){
//    freopen("in.txt", "r", stdin );
    cin>>m;
    long long sum = 0;
    for(int i = 0; i < m; ++i){
        int op;
        cin>>op;
        if( op == 1 ){
            int val;
            cin>>val;
            Map[++sum] = val;
        }else{
            long long l, c;
            cin>>l>>c;
            be.pb( sum + 1);   len.pb( l );
            sum += l * c;
        }
    }
    cin>>n;
    for(int i = 0; i < n; ++i){
        long long num;
        cin>>num;
        cout<<getNum( num )<<" ";
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

const int maxn = 100010;
#define pb push_back
vector<long long> be, len;
map<long long, int> Map;

int m, n;

int getLast(int num){
    int lf = 0, rt = be.size() - 1;
    int ans = -1;
    while( lf <= rt ){
        int mid = (lf + rt) >>1;
        if( be[mid] <= num ){
            ans = mid;
            lf = mid + 1;
        }else
            rt = mid - 1;
    }
    return ans;
}
int getNum(int num ){
    if(Map.find(num) == Map.end() ){
        int id = getLast( num );
        int rem = (num - be[id] )% len[id];
        if( rem == 0 ) rem = len[id];
        Map[num] = getNum( rem );
    }
    return Map[num];
}

int main(){
//    freopen("in.txt", "r", stdin );
    cin>>m;
    long long sum = 0;
    for(int i = 0; i < m; ++i){
        int op;
        cin>>op;
        if( op == 1 ){
            int val;
            cin>>val;
            Map[++sum] = val;
        }else{
            long long l, c;
            cin>>l>>c;
            be.pb( sum );   len.pb( l );
            sum += l * c;
        }
    }
    cin>>n;
    for(int i = 0; i < n; ++i){
        int num;
        cin>>num;
        cout<<getNum( num )<<" ";
    }
    cout<<endl;
    return 0;
}