import sys input = sys.stdin.readline N = int(input()) mod = 10 ** 9 + 7 e = [[] for _ in range(N + 1)] for _ in range(N - 1): u, v = map(int, input().split()) e[u].append(v) root = 0 vis = [0] * (N + 1) for x in range(1, N + 1): if vis[x]: continue root = x vis = [0] * (N + 1) s = [x] while len(s): p = s.pop() for q in e[p]: if vis[q]: continue vis[q] = 1 s.append(q) vis = [0] * (N + 1) size = [1] * (N + 1) parent = [0] * (N + 1) depth = [1] * (N + 1) s = [root] order = [] while len(s): x = s.pop() order.append(x) for y in e[x]: if vis[y]: continue parent[y] = x depth[y] = depth[x] + 1 s.append(y) order.reverse() for y in order[: -1]: x = parent[y] size[x] += size[y] res = 0 for x in range(1, N + 1): for y in e[x]: res += depth[x] * size[y] res %= mod print(res)