use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let b: Vec> = (0..n) .map(|_| { (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect() }) .collect(); let mut ans = -(1i64 << 60); let mut uuu: Vec = vec![]; for bit in 0..1 << n { let mut tmp = 0; let mut tmpu = Vec::new(); for i in 0..n { if bit >> i & 1 == 1 { tmp += a[i]; tmpu.push(i + 1); } } for i in 0..n { for j in i + 1..n { if bit >> i & 1 == 1 && bit >> j & 1 == 1 { tmp += b[i][j]; } } } if tmp > ans { ans = tmp; uuu = tmpu; } } println!("{}", ans); for i in 0..uuu.len() { print!("{} ", uuu[i]); } println!("") }