#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  int M = 200005;
  int v[10][M];
  for (int i = 0; i < 10; i++) {
    v[i][0] = 1;
  }
  map<int, int> mp;
  for (int i = 0; i < 10; i++) {
    mp[i] = 0;
  }
  map<int, int> temp;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      mp[j] = 0;
    }
    mp[i] = 1;
    int l = 1;
    for (int j = 1; j < M; j++) {
      temp = mp;
      for (auto k = mp.begin(); k != mp.end(); k++) {
        int x = k->first, y = k->second;
        if (y == 0) continue;
        if (x < 9) {
          temp[x + 1] += y;
          temp[x] -= y;
        } else {
          temp[x] -= y;
          l = (l + y) % 1000000007;
          temp[1] += y;
          temp[0] += y;
        }
      }
      mp = temp;
      v[i][j] = l;
    }
  }
  while (t--) {
    int n, m;
    cin >> n >> m;
    int x = n;
    int l = 0;
    while (x > 0) {
      l = (l + v[x % 10][m]) % 1000000007;
      x /= 10;
    }
    cout << l << '\n';
  }
  return 0;
}
