#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16;
const int MOD = 1e9 + 7;
typedef decay<decltype(MOD)>::type T;
struct mi {
  T val;
  explicit operator T() const { return val; }
  mi() { val = 0; }
  mi(const long long& v) {
    val = (-MOD <= v && v <= MOD) ? v : v % MOD;
    if (val < 0) val += MOD;
  }
  friend ostream& operator<<(ostream& os, const mi& a) { return os << a.val; }
  friend bool operator==(const mi& a, const mi& b) { return a.val == b.val; }
  friend bool operator!=(const mi& a, const mi& b) { return !(a == b); }
  friend bool operator<(const mi& a, const mi& b) { return a.val < b.val; }
  mi operator-() const { return mi(-val); }
  mi& operator+=(const mi& m) {
    if ((val += m.val) >= MOD) val -= MOD;
    return *this;
  }
  mi& operator-=(const mi& m) {
    if ((val -= m.val) < 0) val += MOD;
    return *this;
  }
  mi& operator*=(const mi& m) {
    val = (long long)val * m.val % MOD;
    return *this;
  }
  friend mi pow(mi a, long long p) {
    mi ans = 1;
    assert(p >= 0);
    for (; p; p /= 2, a *= a)
      if (p & 1) ans *= a;
    return ans;
  }
  friend mi inv(const mi& a) {
    assert(a != 0);
    return pow(a, MOD - 2);
  }
  mi& operator/=(const mi& m) { return (*this) *= inv(m); }
  friend mi operator+(mi a, const mi& b) { return a += b; }
  friend mi operator-(mi a, const mi& b) { return a -= b; }
  friend mi operator*(mi a, const mi& b) { return a *= b; }
  friend mi operator/(mi a, const mi& b) { return a /= b; }
};
mi c[200011];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  mi len = 1;
  vector<long long> digits(10);
  digits[0] = 1;
  c[0] = 1;
  for (long long i = 0; i < 200010; i++) {
    long long d9 = digits[9];
    len += d9;
    c[i + 1] = len;
    for (long long j = 9; j > 0; j--) {
      digits[j] = digits[j - 1];
    }
    digits[0] = d9;
    digits[1] += d9;
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    mi ret = 0;
    while (n > 0) {
      long long digit = n % 10;
      ret += c[m + digit];
      n /= 10;
    }
    cout << ret << endl;
  }
}
