import sys input = sys.stdin.buffer.readline MOD = 1000000007 N = int(input()) tree = [[] for _ in range(N)] par = [None for _ in range(N)] dep = [None for _ in range(N)] cum = [None for _ in range(N)] for i in range(N - 1): u, v = map(int, input().split()) tree[u - 1].append(v - 1) par[v - 1] = u - 1 for i in range(N): if par[i] is None: root = i stack = [root] dep[root] = 0 while stack: node = stack.pop() for adj in tree[node]: if dep[adj] is not None: continue dep[adj] = dep[node] + 1 stack.append(adj) stack = [root] cum[root] = 0 while stack: node = stack.pop() for adj in tree[node]: if cum[adj] is not None: continue cum[adj] = cum[node] + dep[adj] cum[adj] %= MOD stack.append(adj) print(sum(cum) % MOD)