import sys sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] MOD = 10**9+7 n = int(input()) aff = [0 for _ in range(n)] adj = [[] for _ in range(n)] for _ in range(n-1): u, v = map(int, input().split()) adj[u-1].append(v-1) aff[v-1] += 1 for i, x in enumerate(aff): if x == 0: root = i break ans = 0 dp_val = [0 for _ in range(n)] dp_num = [1 for _ in range(n)] ans = 0 def dfs(x): global ans for v in adj[x]: dfs(v) dp_num[x] += dp_num[v] dp_num[x] %= MOD dp_val[x] += dp_val[v] + dp_num[v] dp_val[x] %= MOD ans += dp_val[x] ans %= MOD dfs(root) print(ans)