import sys input = sys.stdin.readline N = int(input()) mod = 10 ** 9 + 7 e = [[] for _ in range(N + 1)] inc = [0] * (N + 1) for _ in range(N - 1): u, v = map(int, input().split()) e[u].append(v) inc[v] += 1 root = 0 for x in range(1, N + 1): if inc[x] == 0: root = x break 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] % mod res %= mod print(res)