import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Queue; import java.util.Scanner; import java.util.TreeMap; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Map> map = new HashMap>(); for (int i = 0; i < n - 1; i++) { int u = sc.nextInt(); int v = sc.nextInt(); List list1 = map.get(u); if (list1 == null) { list1 = new ArrayList(); map.put(u, list1); } list1.add(v); List list2 = map.get(v); if (list2 == null) { list2 = new ArrayList(); map.put(v, list2); } list2.add(u); } sc.close(); int[] dep = new int[n + 1]; Queue que = new ArrayDeque(); que.add(1); dep[1] = 1; while (!que.isEmpty()) { Integer cur = que.poll(); List list = map.get(cur); for (Integer next : list) { if (dep[next] == 0) { que.add(next); dep[next] = dep[cur] + 1; } } } TreeMap depMap = new TreeMap(); for (int i = 1; i <= n; i++) { int key = dep[i]; if (depMap.containsKey(key)) { depMap.put(key, depMap.get(key) + 1); } else { depMap.put(key, 1); } } int mod = 1000000007; long p = 1; int i = 1; long ans = 0; while (!depMap.isEmpty()) { Entry ent = depMap.pollLastEntry(); int k = ent.getKey(); int v = ent.getValue(); for ( ; i <= n - k; i++) { p *= i; p %= mod; } long npr = nPr(n, k); ans += npr * p / k % mod * v % mod; ans %= mod; } System.out.println(ans); } static long nPr(long n, long r) { long m = 1000000007; long val = 1; for (int i = 1; i <= r; i++) { val = val * (n - i + 1) % m; } return val; } }