import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines n, m=map(int, readline().split()) p=[[] for i in range(n)] for i in range(m): a, b, s=map(int, readline().split()) p[b].append((a, s)) dp=[0]*(1<