import sys import io, os #input = sys.stdin.buffer.readline input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n = int(input()) g = [[] for _ in range(n)] ind = [[] for _ in range(n)] for i in range(n-1): a, b = map(int, input().split()) a, b = a-1, b-1 g[a].append(b) ind[b].append(a) root = -1 for i in range(n): if len(ind[i]) == 0: root = i break mod = 10**9+7 s = [] s.append(root) order = [] par = [-1]*n depth = [0]*n while s: v = s.pop() order.append(v) for u in g[v]: if u == par[v]: continue par[u] = v s.append(u) depth[u] = depth[v]+1 child = [[] for _ in range(n)] for v in range(n): if par[v] != -1: child[par[v]].append(v) c = [1]*n order.reverse() for v in order: if par[v] != -1: c[par[v]] += c[v] order.reverse() ans = 0 for v in order: for u in child[v]: ans += (depth[v]+1)*c[u]%mod ans %= mod print(ans)