#include using namespace std; #define INF 1000000007 #define LINF 1000000000000000007 typedef long long i64; typedef pair P; int n, m; vector

v[20]; int main(){ cin >> n >> m; for(int i = 0; i < m; i++){ int a,b,c; cin >> a >> b >> c; v[a].push_back(P(b,c)); v[b].push_back(P(a,c)); } i64 ans = 0; for(int i = 1; i <= n; i++){ bool b[20] = {0}; queue

q; q.push(P(i, 0)); while(!q.empty()){ P p = q.front(); q.pop(); b[p.first] = 1; ans = max(ans, p.second); for(int j = 0; j < v[p.first].size(); j++){ if(b[v[p.first][j].first]) continue; q.push(P(v[p.first][j].first, p.second + v[p.first][j].second)); } } } cout << ans << endl; return 0; }