import std.stdio : readln, write, writef, writeln, writefln; import std.string : chomp; import std.array : array, split; import std.conv : to; import std.range.primitives; import std.range : enumerate, iota, repeat, retro, zip, assumeSorted; import std.algorithm.searching : all, any, canFind, count, countUntil; import std.algorithm.comparison : max, min, clamp; import std.algorithm.iteration : each, group, filter, map, reduce, permutations, sum, uniq; import std.algorithm.sorting : sort; import std.algorithm.mutation : reverse, swap; import std.typecons : Tuple; import std.container; void main() { int n,m; scan(n,m); auto t = new int[][](n, n); foreach (i ; 0 .. m) { int a,b,c; scan(a,b,c); t[a][b] = c; } auto dp = new int[][](1<