#include #define REP(i,n,N) for(int i=(n);i<(int) N;i++) #define p(s) cout<<(s)<>num>>s; if(s=="unlocked") break; sum+=num; REP(j,0,num) q+=(char) '0'+i; } if(s!="unlocked"){ REP(j,0,10-sum) q+='9'; do{ p(q); cin>>num>>s; if(s=="unlocked") break; }while(next_permutation(q.begin(),q.end())); } return 0; }