#include <bits/stdc++.h>
#define x first
#define y second
#define PII pair<int, int>
#define int long long
using namespace std;
const int N = 1e6 + 10;
const int M = N << 1;
const int mod = 1e9 + 7;
int n;
int h[N], e[M], ne[M], w[N], idx;
int dist[N];
bool st[N];
void add(int a, int b)
{
e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}
void dijkstra(int s)
{
memset(dist, 0x3f, sizeof dist);
dist[s] = 0;
priority_queue<PII, vector<PII>, greater<PII> > heap;
heap.push({0, s});
while (heap.size())
{
auto t = heap.top();
heap.pop();
int ver = t.second, distance = t.first;
if (st[ver]) continue;
st[ver] = true;
for (int i = h[ver]; i != -1; i = ne[i])
{
int j = e[i];
if (dist[j] > dist[ver] + 1)
{
dist[j] = dist[ver] + 1;
heap.push({dist[j], j});
}
}
}
}
signed main()
{
memset(h, -1, sizeof h);
cin >> n;
for(int i = 1 ; i < n ; i ++ )
{
int a, b;
cin >> a >> b;
add(a, b);
add(b, a);
}
int ans = 0;
for(int i = 1 ; i <= n ; i ++ )
{
memset(st, 0, sizeof st);
dijkstra(i);
for(int j = 1 ; j < i ; j ++ ) ans = (ans + dist[j] * i % mod * j % mod) % mod;
}
cout << ans;
return 0;
}