import sys input=sys.stdin.readline n=int(input()) edge=[[]for _ in range(n)] to=[0]*n p=[0]*n for _ in range(n-1): a,b=map(int,input().split()) a-=1 b-=1 edge[a].append(b) to[b]=1 stack=[to.index(0)] visited=set(stack) mod=10**9+7 ans=0 for i in stack: for j in edge[i]: if j in visited:continue visited.add(j) stack.append(j) p[j]+=p[i]+1 ans+=p[i]*(p[i]+1)//2 ans%=mod print(ans)