const MOD: usize = 1e9 as usize + 7; 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>, depths: &mut Vec) { for &v in paths[cur].iter() { if prev == v { continue; } depths[v] = depths[cur] + 1; dfs(v, cur, paths, depths); } } 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 _ 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); paths[v].push(u); } let mut depths = vec![0usize; n]; dfs(0, 0, &paths, &mut depths); let total = (1..=n).fold(1usize, |x, y| x * y % MOD); let divs = (1..=n).map(|i| power(i, MOD-2)).collect::>(); let result = depths.iter().map(|&v| divs[v]).sum::() % MOD * total % MOD; println!("{}", result); }