#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef complex P; typedef pair pii; #define REP(i,n) for(ll i=0;i>x>>y; if(x==4&&y==0)return 0; id[i] = x+y; mn = min(mn,x+y); mx = max(mx,x+y); sum += x+y; } int other = sum - mn*7; // 3~9の中に何個あるか vi cand; if(other==1){ int yey = 0; FOR(i,3,10){ if(id[i]==mn+1){ yey = i; break; } } cand.push_back(0); cand.push_back(1); cand.push_back(2); cand.push_back(yey); }else if(other==2){ int a=0,b=0; FOR(i,3,10){ if(id[i]==mn+1){ if(!a)a=i; else b=i; } } vi t(3); REP(i,3)t[i]=i; do{ printf("%d %d %d %d",a,b,t[0],t[1]); cout<>x>>y; if(x==4&&y==0)return 0; if(x+y==4)break; }while(next_permutation(ALL(t))); cand.push_back(t[0]); cand.push_back(t[1]); cand.push_back(a); cand.push_back(b); }else if(other==3){ int a=0,b=0,c=0; FOR(i,3,10){ if(id[i]==mn+1){ if(!a)a=i; else if(!b)b=i; else c=i; } } REP(i,3){ printf("%d %d %d %d",a,b,c,i); cout<>x>>y; if(x==4&&y==0)return 0; if(x+y==4){ cand.push_back(a); cand.push_back(b); cand.push_back(c); cand.push_back(i); break; } } }else if(other==4){ FOR(i,3,10){ if(id[i]==mn+1)cand.push_back(i); } } sort(ALL(cand)); do{ printf("%d %d %d %d",cand[0],cand[1],cand[2],cand[3]); cout<>x>>y; if(x==4&&y==0)return 0; }while(next_permutation(ALL(cand))); return 0; }