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(); ArrayList> graph = new ArrayList<>(); for (int i = 0; i < n; i++) { graph.add(new ArrayList<>()); } boolean[] used = new boolean[n]; for (int i = 0; i < n - 1; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; used[b] = true; graph.get(a).add(b); } ArrayDeque deq = new ArrayDeque<>(); for (int i = 0; i < n; i++) { if (!used[i]) { deq.add(new Path(i, 0)); break; } } long ans = 0; while (deq.size() > 0) { Path p = deq.poll(); ans += (long)p.value + (p.value + 1) / 2 % MOD; ans %= MOD; for (int x : graph.get(p.idx)) { deq.add(new Path(x, p.value + 1)); } } System.out.println(ans); } static class Path { int idx; int value; public Path(int idx, int value) { this.idx = idx; this.value = value; } } }