#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } #include using mint = atcoder::modint998244353; void solve() { long long N; int x; cin >> N >> x; vector n; while (N) { n.push_back(N % 10); N /= 10; } reverse(n.begin(), n.end()); int l = n.size(); vector dp(l + 1, vector(2, vector(2, vector(x + 1, vector(2))))); dp[l][1][1][0][0] = 1; for (int i = l - 1; i >= 0; i--) { for (int smaller_a = 0; smaller_a < 2; smaller_a++) { for (int smaller_b = 0; smaller_b < 2; smaller_b++) { for (int j = 0; j <= x; j++) { for (int carry = 0; carry < 2; carry++) { for (int a = 0; a < 10; a++) { for (int b = 0; b < 10; b++) { int smaller_a_next = (a == n[i]) ? smaller_a : (a < n[i]); int smaller_b_next = (b == n[i]) ? smaller_b : (b < n[i]); if ((a + b + carry) >= 10) { if (j == x) { continue; } dp[i][smaller_a_next][smaller_b_next][j + 1] [1] += dp[i + 1][smaller_a][smaller_b][j] [carry]; } else { dp[i][smaller_a_next][smaller_b_next][j] [0] += dp[i + 1][smaller_a][smaller_b][j] [carry]; } } } } } } } } mint ans = dp[0][1][1][x][0] + dp[0][1][1][x][1]; cout << ans.val() << "\n"; } int main() { fast_io(); int t; cin >> t; for (; t--;) { solve(); } }