const MOD: usize = 998244353; fn power(base: usize, times: usize) -> usize { if times == 0 { return 1usize; } if times == 1 { return base; } let temp = power(base, times/2); temp * temp % MOD * power(base, times%2) % MOD } fn dfs(cur: usize, prev: usize, paths: &Vec>, points: &mut Vec) -> usize { let mut ret = 1usize; for &(v, idx) in paths[cur].iter() { if v == prev { continue; } let val = dfs(v, cur, paths, points); ret += val; points[idx] = val; } ret } fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut paths = vec![vec![]; n]; for i in 0..n-1 { 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 u = temp[0]-1; let v = temp[1]-1; paths[u].push((v, i)); paths[v].push((u, i)); } let mut points = vec![0usize; n-1]; dfs(0, 0, &paths, &mut points); let mut result = 0usize; let total = n * (n-1) / 2; let modval = power(total % MOD, MOD-2); let modval2 = power(n-1, MOD-2); for i in 0..n-1 { let left = points[i]; let right = n - left; result += (left * (left-1) / 2 + right * (right-1) / 2) % MOD * modval % MOD * modval2 % MOD; result %= MOD; } println!("{}", result); }