//interactive struct Q { int q[5]; int&operator[](int i){return q[i];} }; struct S { int q[5]; struct{int h,b;}r[30]; }; S a[30240]; int n=0; int q[5]; int qq[30240][5]; rep_sarr(q,5,10){ qq[n][0..4]=q[0..]; } Rand rnd; int qix[30240],tmp[30240]; rep(i,30240){ tmp[i]=rnd.get(); } sortA_index(n,tmp,qix); n=0; rep[qix](qi,30240){ int*q=qq[qi]; rep(i,n){ int h=0,b=0; rep(k,5){ rep(l,5){ (k==l?h:b)+=q[k]==a[i].q[l]; } } rep(j,30){ if(a[i].r[j].h==5){ goto l_next_q; } if(a[i].r[j].h==h&&a[i].r[j].b==b){ goto l_next_i; } } goto l_next_q; l_next_i:; } wtN(q(5),'\n'); rep(l,5){ a[n].q[l]=q[l]; } rep(j,30){ rd(a[n].r[j].h); rd(a[n].r[j].b); } if(a[n].r[0].h==5){ exit(0); } ++n; l_next_q:; }