#include #include using namespace std; int N,M; long D[100][100]; main() { cin>>N>>M; for(int i=0;i>s>>t>>d; s--,t--; if(D[s][t]>d)D[s][t]=d; } for(int k=0;k