def c(a): if len(a)==0: return 0 if len(a)==1: return 1 while len(a)>1: a=list(map(int,str(sum(a)))) if not all(a[i]<=a[i+1] for i in range(len(a)-1)): return 0 return 1 def f(): if len(q)>15: return if c(q): p.append(int("".join(list(map(str,q))))) for i in range(q[-1] if len(q)>0 else 1,10): q.append(i) f() q.pop() return p=[] q=[] f() p=sorted(p) from bisect import bisect_left,bisect_right T=int(input()) for _ in range(T): n=int(input()) M=998244353 while bisect_right(p,9*(n+1))-bisect_left(p,1*(n+1))==0: n+=1 q=p[bisect_left(p,1*(n+1))] for i in range(1,10): if i+9*n>=q: a=0 a+=(pow(10,n+1,M)-1)*pow(9,M-2,M)*i%M q-=i*(n+1) m=q//(9-i) a+=(pow(10,m,M)-1)*pow(9,M-2,M)*(9-i)%M q-=(9-i)*m a+=q*pow(10,m,M) print(a%M) break