// #pragma GCC optimize ("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target ("avx,avx2,fma") #include using std::cin, std::cout, std::cerr; using ll = long long; const ll P = 998244353; ll Pow(ll a, ll b) { ll r = 1; for(; b; b /= 2) { if(b & 1) r = r * a % P; a = a * a % P; } return r; } ll Inv(ll x) { return Pow(x, P - 2); } int main() { std::ios::sync_with_stdio(false); int T; cin >> T; while(T --) { std::function check = [&](ll x) -> bool { if(x < 10) return true; std::string s = std::to_string(x); for(int i = 0; i + 1 < s.size(); i ++) if(s[i] > s[i + 1]) return false; ll y = 0; for(char c : s) y += c - '0'; return check(y); }; auto make_mono = [](ll x) { std::string s = std::to_string(x); for(int i = 1; i < s.size(); i ++) if(s[i - 1] > s[i]) { for(int j = i; j < s.size(); j ++) s[j] = s[i - 1]; break; } return std::stoll(s); }; ll n; cin >> n; ll x = n + 1; while(!check(x)) { x ++; x = make_mono(x); } x -= n + 1; ll ans = (Pow(10, n + 1) - 1) * Inv(9) % P; ll y = x / 8; ans += (Pow(10, y) - 1) * Inv(9) % P * 8; x -= y * 8; ans += Pow(10, y) * x; ans %= P; cout << ans << '\n'; } }