#include using namespace std; using ll = long long; const ll modc = 998244353; ll N, ans=0; vector xx1(1e5), yy1(1e5), xx2(1e5), yy2(1e5), a(1e5), ten(1e5); vector> E(1e5); void dfs1(ll from, ll p){ xx1[from] = 1; yy1[from] = 1; for (auto to : E[from]){ if (to == p) continue; dfs1(to, from); xx1[from] += xx1[to]; xx1[from] %= modc; yy1[from] += yy1[to]; yy1[from] %= modc; } yy1[from] *= ten[from]; yy1[from] %= modc; } void dfs2(ll from, ll p){ ll xx = 1, yy = 1; for (auto to : E[from]){ if (to == p){ xx += xx2[from]; yy += yy2[from]; xx %= modc; yy %= modc; continue; } xx += xx1[to]; yy += yy1[to]; xx %= modc; yy %= modc; } for (auto to : E[from]){ if (to == p) continue; xx2[to] = (xx+modc-xx1[to]) % modc; yy2[to] = ((yy+modc-yy1[to]) % modc * ten[from]) % modc; dfs2(to, from); } } void dfs3(ll from, ll p){ ll cnt = (yy2[from] * xx1[from]) % modc; for (auto to : E[from]){ if (to == p) continue; cnt += (xx2[to] * yy1[to]) % modc; cnt %= modc; dfs3(to, from); } ans += (cnt * a[from]) % modc; ans %= modc; } ll ndig(ll X){ return (X == 0 ? 0 : ndig(X/10)+1); } ll tn(ll n){ ll res = 1; for (int i=0; i> N; for (int i=0; i> a[i]; ten[i] = tn(ndig(a[i])); a[i] %= modc; ans += (a[i] * N) % modc; ans %= modc; } for (int i=0; i> x >> y; x--; y--; E[x].push_back(y); E[y].push_back(x); } dfs1(0, -1); dfs2(0, -1); dfs3(0, -1); cout << ans << endl; return 0; }