#include #include using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; set ok; set ng; bool c(ll x){ if (ok.count(x)) return true; if (ng.count(x)) return false; string sx = to_string(x); int l = sx.size(); if (l==1) return true; for (int i=0; i sx[i+1]){ ng.insert(x); return false; } } ll y = 0; for (auto d : sx) y += d-'0'; if (c(y)){ ok.insert(x); return true; }else{ ng.insert(x); return false; } } int main(){ set ok; int t; cin >> t; while(t--){ ll n; cin >> n; n++; string sn = to_string(n); int l = sn.size(); string sm = sn.substr(0, 1); for (int i=1; ii) sm += sm.back(); break; } } ll m = stoll(sm); while(!c(m)) m++; ll p = (m - n) / 8; ll q = (m - n) % 8; mint ans = (mint(10).pow(n) - 1) / 9; ans += (mint(10).pow(p) - 1) * 8 /9; ans += q * mint(10).pow(p); cout << ans.val() << endl; } return 0; }