import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) mod=10**9+7 edge=[[] for i in range(n)] Par=[0]*n A=[True]*n for i in range(n-1): a,b=map(int,input().split()) edge[a-1].append(b-1) Par[b-1]=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:-1]: C[Par[TS[i]]]+=C[TS[i]]+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: ans+=(P[Par[i]]+1)*(C[i]+1) if ans>=mod: ans%=mod print(ans)