import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap graph = new HashMap<>(); for (int i = 0; i < n - 1; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; graph.put(b, a); } int[] depth = new int[n]; Arrays.fill(depth, -1); for (int i = 0; i < n; i++) { getDepth(i, graph, depth); } long ans = 0; for (int x : depth) { ans += (long)x * (x + 1) / 2 % MOD; ans %= MOD; } System.out.println(ans); } static int getDepth(int idx, HashMap graph, int[] depth) { if (depth[idx] == -1) { if (graph.containsKey(idx)) { depth[idx] = getDepth(graph.get(idx), graph, depth) + 1; } else { depth[idx] = 0; } } return depth[idx]; } }