import sys input = lambda: sys.stdin.readline().rstrip() from collections import deque N = int(input()) X = [[] for i in range(N)] Y = [0] * N for i in range(N-1): x, y = map(int, input().split()) X[x-1].append(y-1) X[y-1].append(x-1) Y[y-1] += 1 for i in range(N): if Y[i] == 0: s = i break P = [-1] * N Q = deque([s]) D = [0] * N R = [] while Q: i = deque.popleft(Q) R.append(i) for a in X[i]: if a != P[i]: P[a] = i D[a] = D[i] + 1 # X[a].remove(i) deque.append(Q, a) C = [1] * N ans = 0 for i in R[1:][::-1]: C[P[i]] += C[i] ans += D[i] * C[i] print(ans % (10 ** 9 + 7))