import sys sys.setrecursionlimit(10**8) input=sys.stdin.readline def dfs(v,mod): nums[v] = 0 child[v] = 0 if len(edge[v])==0: return for u in edge[v]: if nums[u] == -1: dfs(u,mod) nums[v] += nums[u]+child[u]+1 child[v] += child[u]+1 nums[v] %= mod child[v] %= mod return N = int(input()) mod = 10**9+7 edge = [[] for _ in range(N)] roots = [True]*N for _ in range(N-1): a,b = map(int, input().split()) roots[b-1] = False edge[a-1].append(b-1) nums = [-1]*N child = [-1]*N for i in range(N): if roots[i]==True: dfs(i,mod) break ans = sum(nums) ans %= mod print(ans)