#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 N = 2007; 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); } } } const int MOD = 1000 * 1000 * 1000 + 7; int pw[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 pw[n - 1 - dist[v][k]]; } } int sum = (dist[u][v] + dist[v][k] + dist[u][k]) / 2; return pw[n - 1 - sum]; } 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; 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 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 << ans << endl; }