N, M = map(int, input().split()) scores = [[] for _ in range(N)] for _ in range(M): item1, item2, score = map(int, input().split()) scores[item2].append((item1, score)) dp = [0] * (1<>n)&1: add = 0 for prev, score in scores[n]: if (S>>prev)&1: add += score dp[S] = max(dp[S], dp[S|(1<