#include #include #include using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} const ll MOD=998244353; void solve(){ string s; int x; cin>>s>>x; int n=s.size(); ll dp[20][20][2][2][2]; rep(i,20)rep(j,20)rep(k,2)rep(l,2)rep(m,2)dp[i][j][k][l][m]=0; dp[0][0][0][0][0]=1; reverse(all(s)); rep(i,n){ rep(j,19){ rep(k,2)rep(l,2)rep(m,2){ rep(p,10)rep(q,10){ int fp=(p>s[i]-'0')||(p==s[i]-'0'&&l); int fq=(q>s[i]-'0')||(q==s[i]-'0'&&m); if(p+q+k>=10){ dp[i+1][j+1][1][fp][fq]+=dp[i][j][k][l][m]; dp[i+1][j+1][1][fp][fq]%=MOD; }else{ dp[i+1][j][0][fp][fq]+=dp[i][j][k][l][m]; dp[i+1][j][0][fp][fq]%=MOD; } } } } } ll ans=(dp[n][x][1][0][0]+dp[n][x][0][0][0])%MOD; cout<>t; while(t--){ solve(); } }