List1=[30] //首元素为血量
List2=[30]
flag=1 //回合
n=input()
for i in range(int(n)):
move=input() //读取输入
movelist=move.split(" ")
if movelist[0]=="summon": //召唤随从
loc=int(movelist[1]) //召唤位置
attack=int(movelist[2]) //随从攻击
health=int(movelist[3]) //随从生命
if flag==1:
List1.insert(loc,[attack,health])
else:
List2.insert(loc,[attack,health])
elif movelist[0]=="end": //回合结束
if flag==1:
flag=2
elif flag==2:
flag=1
elif movelist[0]=="attack": //攻击操作
att=int(movelist[1]) //攻击者
defend=int(movelist[2]) //防守者
if flag==1:
john=List1[att] //攻击
tom=List2[defend] //防守
if defend==0: //打脸
List2[0]=List2[0]-john[0]
continue
if john[0]>=tom[1]: //防守者血量计算
List2.pop(defend)
else:
List2[defend][1]=List2[defend][1]-john[0]
if tom[0]>=john[1]: //攻击者血量计算
List1.pop(att)
else:
List1[att][1]=List1[att][1]-tom[0]
else:
john=List2[att]
tom=List1[defend]
if defend==0:
List1[0]=List1[0]-john[0]
continue
if john[0]>=tom[1]:
List1.pop(defend)
else:
List1[defend][1]=List1[defend][1]-john[0]
if tom[0]>=john[1]:
List2.pop(att)
else:
List2[att][1]=List2[att][1]-tom[0]
if List1[0]<=0 or List2[0]<=0:
break
if List1[0]==0:
print(-1)
elif List2[0]==0:
print(1)
else:
print(0)
print(List1[0])
print(len(List1)-1,end=" ")
for i in range(1,len(List1)):
if i!=len(List1)-1:
print(List1[i][1],end=" ")
else:
print(List1[i][1])
if len(List1)==1:
print()
print(List2[0])
print(len(List2)-1,end=" ")
for i in range(1,len(List2)):
if i!=len(List2)-1:
print(List2[i][1],end=" ")
else:
print(List2[i][1])
80分。。。