#include using namespace std; #define int long long #define ii pair #define app push_back #define all(a) a.begin(), a.end() #define bp __builtin_popcountll #define ll long long #define mp make_pair #define f first #define s second #define Time (double)clock()/CLOCKS_PER_SEC #define debug(x) std::cout << #x << ": " << x << '\n'; const int MOD = 1000 * 1000 * 1000 + 7; const int N = 2007; int mod(int n) { n %= MOD; if (n < 0) return n + MOD; else return n; } int fp(int a, int p) { int ans = 1, c = a; for (int i = 0; (1ll << i) <= p; ++i) { if ((p >> i) & 1) ans = mod(ans * c); c = mod(c * c); } return ans; } int dv(int a, int b) { return mod(a * fp(b, MOD - 2)); } int dist[N][N]; vector g[N]; void dfs(int u, int p, int *dist) { for (int v : g[u]) { if (v != p) { dist[v] = dist[u] + 1; dfs(v, u, dist); } } } int pw[N], inv[N]; int n; int get(int u, int v, int k) { vector a = {u, v, k}; for (int i = 0; i < 3; ++i) { int u = a[i]; int v = a[(i + 1) % 3]; int k = a[(i + 2) % 3]; if (dist[u][v] + dist[u][k] == dist[v][k]) { return inv[dist[v][k]]; } } return 0; } int sum[N], h[N]; void calc(int u, int p) { sum[u] = inv[h[u]]; for (int v : g[u]) { if (v != p) { h[v] = h[u] + 1; calc(v, u); sum[u] += sum[v]; sum[u] %= MOD; } } } int solve(int root) { h[root] = 0; calc(root, root); vector d; for (int v : g[root]) d.app(v); int t = 0; for (int v : d) { t += sum[v]; t %= MOD; } int ans = ((t * t) % MOD) * t % MOD; for (int v : d) { ans -= 3 * mod(mod(sum[v] * sum[v]) * t); ans += 2 * mod(mod(sum[v] * sum[v]) * sum[v]); ans = mod(ans); } return ans; } signed main() { #ifdef HOME freopen("input.txt", "r", stdin); #else #define endl '\n' ios_base::sync_with_stdio(0); cin.tie(0); #endif pw[0] = 1; for (int i = 1; i < N; ++i) pw[i] = pw[i - 1] * 2 % MOD; for (int i = 0; i < N; ++i) inv[i] = fp(pw[i], MOD - 2); cin >> n; for (int i = 0; i < n - 1; ++i) { int u, v; cin >> u >> v; g[u].app(v); g[v].app(u); } for (int i = 1; i <= n; ++i) { dfs(i, i, dist[i]); } int ans = 0; for (int i = 1; i <= n; ++i) { ans += solve(i); ans %= MOD; } for (int a = 1; a <= n; ++a) { for (int b = 1; b <= n; ++b) { for (int c = 1; c <= n; ++c) { ans += get(a, b, c); ans %= MOD; } } } cout << mod(ans * pw[n - 1]) << endl; }