//sidcodes #include using namespace std; typedef long long ll; typedef priority_queue, greater> pqmin; #define endl '\n' #define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define fi first #define se second #define fr(i,n) for(int i=0;i pii; typedef pair pll; typedef vector vi; typedef vector vll; typedef vector vpll; typedef vector vpii; typedef vector vvll; const int MOD = 1e9+7; #ifndef ONLINE_JUDGE #define debug(x) cerr << #x << " = "; _print(x); cerr << endl; #else #define debug(x) #endif void _print(int t) {cerr << t;} void _print(string t) {cerr << t;} void _print(char t) {cerr << t;} void _print(long double t) {cerr << t;} void _print(double t) {cerr << t;} void _print(unsigned long long t) {cerr << t;} void _print(long long t) {cerr << t;} template void _print(pair p); template void _print(vector v); template void _print(set v); template void _print(map v); template void _print(multiset v); template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } vector fact, invfact; ll modpow(ll a, ll b, ll mod = MOD) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; } void init_nck(int maxn){ fact.assign(maxn+1, 1); invfact.assign(maxn+1, 1); for(int i = 1; i <= maxn; i++) fact[i] = (fact[i-1] * i) % MOD; invfact[maxn] = modpow(fact[maxn], MOD - 2); for(int i = maxn-1; i >= 0; i--) invfact[i] = (invfact[i+1] * (i+1)) % MOD; } ll nck(ll n, ll r){ if(r < 0 || r > n) return 0; return (((fact[n] * invfact[r]) % MOD) * invfact[n-r]) % MOD; } vector adj; vll depth, parent, sub; vector dp; void dfs(ll u, ll p) { parent[u] = p; sub[u] = 1; for (auto v : adj[u]) { if (v == p) continue; depth[v] = depth[u] + 1; dfs(v, u); sub[u] += sub[v]; } } void solve() { ll n,k; cin>>n>>k; ll cnt=0; for(int i=1;i<=n;i++){ string s=to_string(i); ll sum=0; for(auto c:s){ sum+=(c-'0'); } cnt+=(sum==k); } cout<> t; while (t--) { solve(); } return 0; }