import sequtils,algorithm template times*(n:int,body) = (for _ in 0.." .} proc scan(): int32 = while true: var k = getchar_unlocked() if k < '0' or k > '9': break else: result = 10 * result + k.ord.int32 - '0'.ord.int32 let n = scan() let m = scan() var N = newSeqWith(n,newSeq[int32](n)) m.times: let (i1,i2,s) = (scan(),scan(),scan()) N[i1][i2] = s var p = toSeq(0.int32..