#include #include #include #include #include using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; using vi = vector; using vvi = vector; using vvvi = vector; using vll = vector; using vvll = vector; using vvvll = vector; using vmi = vector; using vvmi = vector; using vvvmi = vector; #define all(a) (a).begin(), (a).end() #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) ll mono(ll s){ string t = to_string(s); int len = t.length(); rep(i, len-1){ int a = t[i] - '0'; int b = t[i+1] - '0'; if(a > b){ vector v(len); rep(j, i)v[j] = t[j]; rep2(j, i, len)v[j] = t[i]; string res(v.begin(), v.end()); return stoll(res); } } return s; } ll keta(ll s){ string t = to_string(s); int len = t.length(); ll res = 0; rep(i, len)res += t[i] - '0'; return res; } int main(){ int t; cin >> t; while(t--){ ll n; cin >> n; if(n <= 8){ string s; rep(i, n+1)s.append("1"); ll u = stoll(s); mint ans = mint(u); cout << ans.val() << endl; continue; } ll base = n+1; while(true){ ll c = mono(base); ll w = c; bool f = true; while(w > 9){ if(mono(keta(w)) != keta(w)){ f = false; break; } w = keta(w); } if(f){ base = c; break; } if(c == base){ base++; }else{ base = c; } } ll amari = base - n - 1; ll cnine = amari/8; ll nokori = (amari%8)+1; mint ans = (mint(10).pow(cnine) - mint(1)); mint bb = mint(10).pow(cnine); ans += bb*mint(nokori); ll cone = n - cnine; mint ss = (mint(10).pow(cone) - mint(1))/mint(9); ans += ss*mint(10).pow(cnine+1); cout << ans.val() << endl; } return 0; }