#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) mt19937 rn(28); vectorp; vectorv(10,false); string s; void dfs(int i){ if(i==5){ p.push_back(s); return ; } rep(j,10){ if(v[j])continue; v[j]=true; s.push_back(j+'0'); dfs(i+1); s.pop_back(); v[j]=false; } return ; } using pii = pair; pii hitblow(string s,string t){ int h=0,b=0; rep(i,5)rep(j,5){ if(s[i]==t[j]){ if(i==j)h++; else b++; } } return {h,b}; } int main(){ dfs(0); shuffle(p.begin(),p.end(),rn); const int x=30; vectorq; vector>v; int cnt=0; for(string s:p){ if(cnt==x)break; bool ok=true; int m=q.size(); rep(i,m){ if(v[i].count(hitblow(s,q[i]))==0){ ok=false; break; } } if(!ok)continue; q.push_back(s); v.push_back({}); cout << s << endl; rep(i,x){ int h,b; cin >> h >> b; if(i