#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int _t; cin>>_t; rep(_,_t){ long long n,x; cin>>n>>x; string s = to_string(n); reverse(s.begin(),s.end()); s.push_back('0'); vector dp(2,vector(2,vector(2,vector(x+1)))); dp[0][0][0][0] = 1; rep(i,s.size()){ int xx = s[i]-'0'; vector ndp(2,vector(2,vector(2,vector(x+1)))); rep(j,2){ rep(k,2){ rep(m,2){ rep(l,x+1){ if(dp[j][k][m][l]==0)continue; rep(a,10){ rep(b,10){ int jj = j,kk = k; if(axx)jj = 1; if(bxx)kk = 1; int ll = l; int mm = 0; if(m+a+b>=10){ ll++; mm = 1; } if(ll>x)continue; ndp[jj][kk][mm][ll] += dp[j][k][m][l]; } } } } } } swap(dp,ndp); } cout<