#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#include <ctime>
#include <random>
#include <chrono>
using namespace std;

template<class T> istream& operator >> (istream& is, vector<T>& vec){for(T& val: vec) is >> val; return is;}
template<class T> istream& operator ,  (istream& is, T& val){ return is >> val;}
template<class T> ostream& operator << (ostream& os, const vector<T>& vec){for(int i=0; i<vec.size(); i++) os << vec[i] << (i==vec.size()-1?"":" "); return os;}
template<class T> ostream& operator ,  (ostream& os, const T& val){ return os << " " << val;}
template<class T> ostream& operator >> (ostream& os, const T& val){ return os << " " << val;}

int main(){
	vector<int> n = {0,1,2,3};
	set<int> s;
	
	for(int i=0; i<10; i++){
		n = {i, (i+1)%10, (i+2)%10, (i+3)%10};
		int a,b;
		cout << n << endl;
		cin >> a,b;
		if(a==4 && b==0) return 0;

		for(int k=4; k<10; k++){
			n[0] = (i+k)%10;
			int c,d;
			cout << n << endl;
			cin >> c,d;
			if(c==4 && d==0) return 0;
			if(a+b > c+d){
				s.insert(i);
				break;
			}
		}
	}

	n = vector<int>(s.begin(), s.end());
	do{
		cout << n << endl;
		int a,b;
		cin >> a >> b;
		if(a==4 && b==0){
			return 0;
		}
	}while(next_permutation(n.begin(), n.end()));
	abort();
	return 0;
	
}