/* * * ^v^ * */ #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define iamtefu ios_base::sync_with_stdio(false); cin.tie(0); #define ll long long int #define ld long double #define fl(i,a,n) for (ll i(a); i=a; i--) #define print(a) for (auto x:a){cout<>tt; for(;tt--;) template decltype(auto) max(T1 a, T2 b){return (a>b?a:b);} template decltype(auto) min(T1 a, T2 b){return (a>=1; } return res; } const ll mod = 998244353; void scn(){ ll n, m; cin>>n>>m; if (n<=m){ cout<<(pw(10, n, mod)-1+mod)%mod<<'\n'; } else { n%=(2*m); if (n>m){ cout<<(((pw(10, n, mod)-1+mod)%mod)*(pw(10, (m-n)%m, mod)))%mod<<'\n'; } else { cout<<((pw(10, n, mod)-1+mod)%mod)%mod<<'\n'; } } } int main(){ iamtefu; #if defined(airths) auto t1=chrono::high_resolution_clock::now(); freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif tt { scn(); } #if defined(airths) auto t2=chrono::high_resolution_clock::now(); ld ti=chrono::duration_cast(t2-t1).count(); ti*=1e-6; cerr<<"Time: "<