import random import sys input_count=0 def standing(): #"""提出時はコメントアウトを解除 return map(int,input().split()) #""" ret=tuple(map(int,input().split()))+(2000000,) for i in range(10): D[i]=float(input()) return ret def sell(L): global money,S,P,R,score #"""提出時はコメントアウトを解除 print(1,*L,flush=True) money=int(input()) assert money>=0 S=list(map(int,input().split())) P=list(map(int,input().split())) R=list(map(int,input().split())) return money,S,P,R #""" print(1,*L) Z=list(map(float,input().split())) for i in range(10): R[i]+=L[i] S[i]=int(min(R[i],(R[i]**0.5)*(1.05**P[i])*D[i]*Z[i])) score+=S[i] money-=L[i]*500 money+=S[i]*1000 if R[i]!=0: if S[i]<0.1*R[i]: P[i]-=1 if S[i]>=0.3*R[i]: P[i]+=1 P[i]=max(-60,min(P[i],60)) R[i]-=S[i] assert score>=0 return money,S,P,R def adv(x): global money,S,P,R,score #"""提出時はコメントアウトを解除 print(2,x,flush=True) money=int(input()) assert money>=0 S=list(map(int,input().split())) P=list(map(int,input().split())) R=list(map(int,input().split())) return money,S,P,R #""" print(2,x) Z=list(map(float,input().split())) for i in range(10): P[i]=max(-60,min(P[i]+x,60)) money-=pow(2,x-1)*500000 for i in range(10): S[i]=int(min(R[i],(R[i]**0.5)*(1.05**P[i])*D[i]*Z[i])) score+=S[i] money+=S[i]*1000 if R[i]!=0: if S[i]<0.1*R[i]: P[i]-=1 if S[i]>=0.3*R[i]: P[i]+=1 P[i]=max(-60,min(P[i],60)) R[i]-=S[i] assert score>=0 return money,S,P,R def calc(): global add global count for i in range(10): if R[i]+L[i]!=0: add[i]+=S[i]/(((R[i]+L[i])**0.5)*(1.05**P[i])) count[i]+=1 pre=5 score=0 ad=41 D=[1]*10 T,N,money=standing() S=[0 for i in range(N)] P=[0 for i in range(N)] R=[0 for i in range(N)] add=[0 for i in range(N)] count=[0 for i in range(N)] bef=set(range(10)) cnt=0 #money,S,P,R=adv(2) for i in range(pre): L=[0]*N for j in range(10): lf=1 ri=998244353 while ri-lf>1: mid=(lf+ri)//2 if (mid**0.5)*(10/3)*(1.05**P[j])*0.5>=mid: lf=mid else: ri=mid L[j]=lf-R[j] if P[j]=i and j in bef: now.add(j) if now==bef and now!=set(range(10)): cnt+=1 if cnt==3: pre=i+1 break else: cnt=0 bef=now ad=40-pre use=set() for i in range(10): if P[i]>=pre-1: use.add(i) if len(use)==0: for i in range(10): if P[i]==max(P): use.add(i) for i in range(ad): if money>1000000: money,S,P,R=adv(2) else: L=[0]*N for j in use: lf=1 ri=998244353 while ri-lf>1: mid=(lf+ri)//2 if (mid**0.5)*(10/3)*(1.05**P[j])*(add[j]/count[j])*0.7>=mid: lf=mid else: ri=mid L[j]=max(0,min((money//500)//len(use),lf-R[j])) money,S,rP,rR=sell(L) calc() P=rP[:] R=rR[:] for i in range(T-ad-pre): L=[0]*N plus=0 for j in use: plus+=add[j]**2 for j in use: L[j]=int((money//500)*(add[j]**2)//plus) money,S,rP,rR=sell(L) calc() P=rP[:] R=rR[:] print(score,file=sys.stderr)