#include #include using namespace std; typedef long long ll; ll mod = 998244353; ll calc(ll a_max, ll b_max, ll x, ll hascarry, map, pair>, ll> &mp){ //cout << a_max << " " << b_max << " " << x << " " << hascarry << endl; ll ans = 0; if (a_max == 0 && b_max == 0){ if (x == 0){ return 1LL; } else{ return 0LL; } } for (ll i = 0; i < 10; i++){ for (ll j = 0; j < 10; j++){ if (a_max - i < 0) continue; if (b_max - j < 0) continue; pair p1 = pair((a_max - i) / 10, (b_max - j) / 10); ll next_carry = (i + j + hascarry) / 10; pair p2 = pair(x - next_carry, next_carry); //cout << (a_max - i) / 10 << " " << (b_max - j) / 10 << " " << x - next_carry << " " << next_carry << endl; if (mp.find(pair,pair>(p1, p2)) != mp.end()){ ans = (ans + mp[pair, pair>(p1, p2)]) % mod; } else{ mp[pair, pair>(p1, p2)] += calc((a_max - i) / 10, (b_max - j) / 10, x - next_carry, next_carry, mp); ans = (ans + mp[pair, pair>(p1, p2)]) % mod; } } } return ans; } int main(){ ll T; cin >> T; while(T--){ ll N, X; cin >> N >> X; map, pair>, ll> mp; cout << calc(N, N, X, 0, mp) << endl; } }