#include #include #include #include #include #include #include #include #include #include using namespace std; using Graph = vector>; #define MOD 998244353 vector depth; vector subtree_size; void dfs(const Graph& G, int v, int p, int d) { depth[v] = d; for (auto nv : G[v]) { if (nv == p) continue; dfs(G, nv, v, d + 1); } subtree_size[v] = 1; for (auto c : G[v]) { if (c == p) continue; subtree_size[v] += subtree_size[c]; } } long long modinv(long long a, long long mod) { long long b = mod, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= mod; if (u < 0) u += mod; return u; } int main() { long long N; cin >> N; Graph G(N); for (int i = 0; i < N - 1; i++) { int a, b; cin >> a >> b; G[a - 1].push_back(b - 1); G[b - 1].push_back(a - 1); } depth.assign(N, 0); subtree_size.assign(N, 0); dfs(G, 0, -1, 0); long long sum = 0; for (int i = 1; i < N; i++) sum += (N * (N - 1) / 2 - subtree_size[i] * (N - subtree_size[i])) % MOD; sum = sum * modinv(N * (N - 1) / 2, MOD) % MOD * modinv(N - 1, MOD) % MOD; cout << sum << endl; }