import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N=I() to=[[]for _ in range(N)] fro=[[]for _ in range(N)] for _ in range(N-1): a,b=MI() a-=1 b-=1 to[a].append(b) fro[b].append(a) root=0 for i in range(N): if fro[i]==[]: root=i break import queue q=queue.Queue() q.put(root) D=[0]*N while not q.empty(): v=q.get() for nv in to[v]: D[nv]=D[v]+1 q.put(nv) ch=[0]*N#子を根とする木のサイズ used=[0]*N for i in range(N): if to[i]==[]: q.put(i) used[i]=1 while not q.empty(): v=q.get() for nv in fro[v]: ch[nv]+=ch[v]+1 if used[nv]==0: q.put(nv) used[nv]=1 ans=0 for i in range(N): temp=(D[i])*(ch[i]+1) ans=(ans+temp)%mod print(ans) main()