#include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n,m; cin >> n >> m; vector> d(n,vector(n,1e18)); for(int i=0;i> x >> y; x--;y--; ll w; cin >> w; d[x][y]=min(d[x][y],w); } for(int k=0;k