#include using namespace std; typedef long long ll; typedef pair P; int main(){ const ll INF=1000000000000000000; ll i,j,k,n,m; cin >> n >> m; ll dp[110][110]; for(i=0;i> s >> t >> d; s--,t--; dp[s][t]=min(dp[s][t],d); } for(i=0;i