import sys input = sys.stdin.readline N=int(input()) E=[[] for i in range(N+1)] mod=10**9+7 D=[0]*(N+1) D[0]=-1 P=[-1]*(N+1) for i in range(N-1): x,y=map(int,input().split()) E[x].append(y) P[y]=x D[y]+=1 Parents=[1]*(N+1) Children=[1]*(N+1) R=D.index(0) Q=[R] TOP_SORT=[] while Q: x=Q.pop() TOP_SORT.append(x) for to in E[x]: Parents[to]=Parents[x]+1 Q.append(to) for t in TOP_SORT[::-1][:-1]: Children[P[t]]+=Children[t] ANS=0 for i in range(1,N+1): for to in E[i]: ANS=(ANS+Parents[i]*Children[to])%mod #print(i,to,Parents[i],Children[to]) print(ANS)