signedmain() { // ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n >> m; memset(g, 0x3f, sizeof g); while (m --) { int a, b, c; cin >> a >> b >> c; g[a][b] = g[b][a] = min(g[a][b], c) } memcpy(d, g, sizeof d); int res = INF; for (int k = 1; k <= n; k ++) { for (int i = 1; i < k; i ++) for (int j = i + 1; j < k; j ++) res = min(res, d[i][j] + g[i][k] + g[k][j]); for (int i = 1; i <= n; i ++) for (int j = 1; j <= n; j ++) d[i][j] = d[j][i] = min(d[i][j], d[i][k] + d[k][j]); } if (res == INF) cout << "No solution."; else cout << res << '\n'; return0; }