const INF: isize = 1isize << 60; fn main() { let mut nm = String::new(); std::io::stdin().read_line(&mut nm).ok(); let nm: Vec = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nm[0]; let m = nm[1]; let mut paths = vec![vec![-INF; n]; n]; for _ in 0..m { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let a = temp[0]-1; let b = temp[1]-1; let c = temp[2] as isize; paths[a][b] = paths[a][b].max(c); paths[b][a] = paths[b][a].max(c); } let mut dp = vec![vec![-INF; n]; 1<> to) & 1) == 1 { continue; } if paths[from][to] == -INF { continue; } let nidx = i | (1 << to); dp[nidx][to] = dp[nidx][to].max(dp[i][from] + paths[from][to]); } } } println!("{}", dp.iter().map(|v| v.iter().max().unwrap()).max().unwrap()); }