import sys sys.setrecursionlimit(10**7) MOD=10**9+7 N=int(input()) g=[[] for _ in range(N+1)] sz=[0]*(N+1) root=-1 deg=[0]*(N+1) for _ in range(N-1): a,b=map(int,input().split()) g[a].append(b) g[b].append(a) deg[b]+=1 for i in range(1,N+1): if deg[i]==0: root=i ans=0 def dfs(cur,par,d): global ans sz[cur]=1 for dst in g[cur]: if dst==par: continue dfs(dst,cur,d+1) sz[cur]+=sz[dst] ans+=sz[dst]*(d+1)%MOD if ans>=MOD: ans-=MOD dfs(root,-1,0) print(ans)