#include #include #include #include #include #include #include using namespace std; using ll = long long; ll ans = 0; struct Graph { struct Vertex { int n; }; struct Edge { int i, n; }; Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {} void add_edge(int i, int j) { e[m] = { j, v[i].n }; v[i].n = m; m++; } void dfs(int i, int d) { for (int j = v[i].n; j >= 0; j = e[j].n) { Edge& o = e[j]; dfs(o.i, d + 1); } ans += (ll)d * (d + 1) / 2; } vector v; vector e; int n, m; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; Graph g(n, (n - 1) * 2); int x = 0; for (int i = 0; i < n - 1; i++) { int a, b; cin >> a >> b; a--; b--; g.add_edge(a, b); x ^= b; } for (int i = n & ~3; i < n; i++) { x ^= i; } g.dfs(x, 0); cout << ans % 1000000007 << endl; return 0; }