import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) deg=[0]*n edge=[[] for _ in range(n)] edge_r=[[] for _ in range(n)] E=[] for _ in range(n-1): a,b=map(int,input().split()) edge[a-1].append(b-1) edge_r[b-1].append(a-1) E.append((a-1,b-1)) deg[b-1]+=1 from collections import deque TS = list(v for v in range(n) if deg[v]==0) deq = deque(TS) used = [0]*n while deq: v = deq.popleft() for t in edge[v]: deg[t] -= 1 if deg[t]==0: deq.append(t) TS.append(t) L,R=[0]*n,[0]*n for i in range(n): v=TS[i] for g in edge[v]: L[g]+=L[v]+1 for i in range(n)[::-1]: v=TS[i] for g in edge_r[v]: R[g]+=R[v]+1 ans=0 mod=10**9+7 for a,b in E: ans+=(L[a]+1)*(R[b]+1) print(ans%mod)