#include #include #include using namespace std; template struct modint{ long long val; modint(): val(0) {} modint(long long x){ if(x < 0) val = x % MOD + MOD; else val = x % MOD; } modint(const modint &t){ val = t.val; } modint& operator =(const modint m){ val = m.val; return *this; } modint operator -(){ return modint(-val); } modint& operator-=(const modint &m){ val -= m.val; if(val < 0) val += MOD; return *this; } modint& operator+=(const modint &m){ val += m.val; if(val >= MOD) val -= MOD; return *this; } modint& operator*=(const modint &m){ val *= m.val; val %= MOD; return *this; } modint& operator/=(modint m){ *this *= m.inv(); return *this; } modint inv(){ long long x = 1, y = 0; long long a = val, b = MOD; while(b != 0){ long long t = a / b; a -= t * b; x -= t * y; swap(a, b); swap(x, y); } x %= MOD; if(x < 0) x += MOD; return modint(x); } modint pow(long long k){ long long res = 1; long long v = val; while(k > 0){ if(k & 1) res = res * v % MOD; v = v * v % MOD; k >>= 1; } return modint(res); } modint operator==(const modint &m){ return val == m.val; } modint operator+(const modint &m){ return modint(*this) += m; } modint operator-(const modint &m){ return modint(*this) -= m; } modint operator*(const modint &m){ return modint(*this) *= m; } modint operator/(const modint &m){ return modint(*this) /= m; } bool operator!=(const modint &m){ return modint(*this).val != m.val; } bool operator!=(const int &m){ return modint(*this).val != m; } }; const int MOD = 998244353; using mint = modint; long long dfs(int now, int par, vector>&G, vector&depth, vector&cnt){ for(int t: G[now]){ if(t != par){ depth[t] = depth[now] + 1; cnt[now] += dfs(t, now, G, depth, cnt); } } cnt[now]++; return cnt[now]; } int main(){ long long N; cin >> N; vector> G(N); vector A(N - 1), B(N - 1); for(int i = 0; i < N - 1; i++){ int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); A[i] = a; B[i] = b; } mint bo = N * (N - 1) / 2 * (N - 1); vector depth(N), cnt(N); dfs(0, -1, G, depth, cnt); mint si = 0; for(int i = 0; i < N - 1; i++){ if(depth[A[i]] > depth[B[i]]){ si += (N - cnt[A[i]]) * cnt[A[i]]; } else{ si += (N - cnt[B[i]]) * cnt[B[i]]; } } si = bo - si; bo = bo.inv(); cout << (bo * si).val << endl; }