#include using namespace std; using ll = long long; bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; } bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; } #include using mint = atcoder::modint998244353; bool monotone(ll N) { string S = to_string(N); for (int i = 1; i < ssize(S); i++) { if (S[i] < S[i - 1]) return false; } return true; } ll D(ll N) { ll R = 0; while (N > 0) { R += N % 10; N /= 10; } return R; } bool f(ll N) { if (!monotone(N)) return false; return N < 10 ? true : f(D(N)); } ll g(ll N) { auto S = to_string(N); char X = '0'; bool fn = false; for (char &c : S) { if (fn) { c = X; continue; } if (c < X) { c = X; fn = true; } else { X = c; } } return stoll(S); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { ll N; cin >> N; ll M = ++N; while (!f(M)) { if (!monotone(M)) M = g(M); else M++; } mint ans = (mint(10).pow(N) - 1) / 9; M -= N; ll K = M / 8; M %= 8; ans += 8 * ((mint(10).pow(K) - 1) / 9); ans += M * mint(10).pow(K); cout << ans.val() << '\n'; } }