import java.util.*; public class Main { static ArrayList> graph = new ArrayList<>(); static ArrayList> rgraph = new ArrayList<>(); static int[] children; static int[] rchildren; static final int MOD = 1000000007; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] aArr = new int[n - 1]; int[] bArr = new int[n - 1]; children = new int[n]; rchildren = new int[n]; for (int i = 0; i < n; i++) { graph.add(new ArrayList<>()); rgraph.add(new ArrayList<>()); } for (int i = 0; i < n - 1; i++) { aArr[i] = sc.nextInt() - 1; bArr[i] = sc.nextInt() - 1; graph.get(aArr[i]).add(bArr[i]); rgraph.get(bArr[i]).add(aArr[i]); } for (int i = 0; i < n; i++) { if (children[i] == 0) { getChildren(i); } if (rchildren[i] == 0) { getRChildren(i); } } long ans = 0; for (int i = 0; i < n - 1; i++) { ans += (long)(rchildren[aArr[i]]) * children[bArr[i]] % MOD; ans %= MOD; } System.out.println(ans); } static int getChildren(int idx) { children[idx] = 1; for (int x : graph.get(idx)) { children[idx] += getChildren(x); } return children[idx]; } static int getRChildren(int idx) { rchildren[idx] = 1; for (int x : rgraph.get(idx)) { rchildren[idx] += getRChildren(x); } return rchildren[idx]; } }