#include using namespace std; using lint = long long; struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i> N; vector> to(N), from(N); REP(_, N - 1) { int a, b; cin >> a >> b; to[a - 1].emplace_back(b - 1), from[b - 1].emplace_back(a - 1); } int r = 0; while (from[r].size()) r++; lint ret = 0; auto dfs = [&](auto &&rec, int now, lint d) -> void { for (int nxt : to[now]) { rec(rec, nxt, d + 1); } ret += d * (d + 1) / 2; ret %= 1000000007; }; dfs(dfs, r, 0); cout << ret << '\n'; }