#include "bits/stdc++.h" using namespace std; // #define LOCAL using usize=unsigned long long; using i64=long long; using f64=double; template using Vec=vector; __attribute__((constructor)) void constructor(){cin.tie(nullptr);cin.sync_with_stdio(false);} namespace rnd{ static usize S=88172645463325252; inline usize next(){ S^=S<<7; S^=S>>9; return S; } } inline f64 get_time(){ static f64 START=-1.; timespec ts; timespec_get(&ts,TIME_UTC); f64 t=f64(ts.tv_sec)+f64(ts.tv_nsec)*1e-9; if(START<0){START=t;} return t-START; } #ifdef LOCAL #define debug(...) debug_sub(0,#__VA_ARGS__,__VA_ARGS__) template void debug_sub(int i,const N& name,const T& a){ for(;name[i]!=',' && name[i]!='\0';++i) cerr< void debug_sub(int i,const N& name,const T1& a,const T2& ...b){ for(;name[i]!=',' && name[i]!='\0';++i) cerr<,2>,N> edge{}; inline In(){ usize id[3]; usize f[3]; for(usize i=0;i>id[0]>>id[1]>>id[2]>>f[0]>>f[1]>>f[2]; for(usize j=0;j<3;++j){ edge[id[j]][f[j]].emplace_back(i); } } } }; struct Out{ array out{}; array cnt{}; array,2>,N> edge{}; inline Out(){ usize r=!0; for(usize i=0;i>=1; } } inline void re(In& input,usize r){ cnt.fill(0); for(usize i=0;i th; for(;;){ if((iter&2047)==0){ if(get_time()>=TL) break; f64 p=f64(iter)/f64(lim); if(p>=1.) break; constexpr f64 T=0.3; f64 heat=T*(1.-p); usize id=0; do{ usize r=rnd::next(); th[id]=heat*log(f64(r&4294967295)/4294967296.); th[id+1]=heat*log(f64(r>>32)/4294967296.); id+=2; }while(id solve(In& input){ Out out; array ans=out.out; usize best=0; usize pos=1000; usize iter=0; while(get_time()<=TL){ ++iter; out.re(input,pos); if(sa(pos,out,2000000)){ ans=out.out; best=pos; pos+=4; } else{ out.out=ans; pos=best+1; } } debug(iter); debug(best); return ans; } int main(){ In input; array ans=solve(input); for(i64 i=ans.size()-1;0<=i;--i){ cout<