#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(ll i=0;i S; for(i=0;i<10;i++){ for(j=0;j<10;j++){ if(j==i) continue; for(k=0;k<10;k++){ if(k==i || k==j) continue; for(l=0;l<10;l++){ if(l==i || l==j || l==k) continue; for(m=0;m<10;m++){ if(m==i || m==j || m==k || m==l) continue; string s; s+=char(i+'0'); s+=char(j+'0'); s+=char(k+'0'); s+=char(l+'0'); s+=char(m+'0'); S.push_back(s); } } } } } map> mp; string x="02468"; REP(i,30240){ if(S[i]==x) continue; ll e=0; set t; REP(j,5){ if(x[j]==S[i][j]) e++; else{ t.insert(x[j]); t.insert(S[i][j]); } } int h=e,b=2*(5-e)-(int)t.size(); string c; c+=char(h+'0'); c+=char(b+'0'); mp[c].push_back(S[i]); } cout << "02468" << endl; cout.flush(); REP(i,30){ int x,y; cin >> x >> y; if(i==0){ if(x==5) return 0; } if(x==-1 && y==-1) return 0; string z; z+=char(x+'0'); z+=char(y+'0'); vector d=mp[z]; REP(j,d.size()){ cout << d[j] << endl; cout.flush(); REP(k,30){ int xx,yy; cin >> xx >> yy; if(xx==-1 && yy==-1) return 0; if(k==0){ if(xx==5) return 0; } } } } return 0; }