#include #include using namespace std; typedef long long ll; typedef pair pll; typedef pair plb; map,ll> mp; ll mod = 998244353; ll solve(ll a,ll b,ll c,bool f){ //cout << a << " " << b << " "<< c << " " << f << endl; if(a==0 && b==0){ if(!c) return 1; else return 0; } if(a<0 || b<0) return 0; if(mp.find({{a,b},{c,f}})!=mp.end()) return mp[{{a,b},{c,f}}]; ll ans = 0; ll car = f; for(ll i=0;i<=9;i++){ for(ll j=0;j<=9;j++){ ll nxa = a/10 - (i>a%10); ll nxb = b/10 - (j>b%10); ll nxc = (i + j + car>=10) ? c - 1 : c; bool nxf = i + j + car>=10; (ans += solve(nxa,nxb,nxc,nxf)) %= mod; } } return mp[{{a,b},{c,f}}] = ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while(t){ t--; mp.clear(); ll n,x; cin >> n >> x; cout << solve(n,n,x,false) << "\n"; } }