import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) mod=10**9+7 edge=[[] for i in range(n)] edge_r=[[] for i in range(n)] A=[True]*n for i in range(n-1): a,b=map(int,input().split()) edge[a-1].append(b-1) edge_r[b-1].append(a-1) A[b-1]=False for i in range(n): if A[i]: root=i break TS=[root] S=[root] while S: s=S.pop() for g in edge[s]: TS.append(g) S.append(g) ans=0 C=[0]*n for i in range(n)[::-1]: s=TS[i] for g in edge_r[s]: C[g]+=C[s]+1 P=[0]*n for i in range(n): s=TS[i] for g in edge[s]: P[g]+=P[s]+1 for i in range(n): if i!=root: s,g=edge_r[i][0],i ans=(ans+(P[s]+1)*(C[g]+1))%mod print(ans)