n, m = map(int, input().split()) # 容量为n,物品为m primary, annex = {}, {} # 创建空字典分别存放主、附件 for i in range(1, m + 1): v, p, q = map(int, input().split()) if q == 0: primary[i] = [v, p] else: if q not in annex: # 附件1 annex[q] = [[v, p]] #这里一定要双重[],如果是=[v,p],则添加附件2时...