@[Rampage] Blue.Mary mentioned that his algo’s complexity is O(log(T)*n^3). Now the O(log^2(n)*n^3) algo is almost obvious: one builds a graph and binary searches over the largest power of that matrix such that its smallest entry is still at most T. But how to shave off the additional log(T) factor?