# 0を受け取った時の処理 def come_customer(sushiya:list, table:int, kuitai:list) -> None: if len(sushiya[table]) == 0: sushiya[table].append(kuitai) else: raise ValueError("すでに客がいます") # 1を受け取った時の処理 def offer_sushi(sushiya:list, neta:str) -> None: for table in range(20): # 客がいなければスルー if len(sushiya[table]) == 0: continue # 客がいれば食いたいリストを探索。とった人の番号を出力 else: if neta in sushiya[table][0]: sushiya[table][0].remove(neta) print(table+1) return # 誰もとらなければ-1 print(-1) # 2を受け取った時の処理 def go_customer(sushiya:list, table:int): sushiya[table].clear() # 寿司屋の初期化 sushiya = [[] for _ in range(20)] N = int(input()) # クエリを順次受け取る for i in range(N): data = list(input().split()) if data[0] == "0": table = int(data[1]) cap = int(data[2]) kuitai = data[3:] come_customer(sushiya, table-1, kuitai) elif data[0] == "1": neta = data[1] offer_sushi(sushiya, neta) elif data[0] == "2": table = int(data[1]) go_customer(sushiya,table-1)