#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define endl "\n"
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,n) for(int i=1;i<=n;i++)
#define inp(arr,s,e) for(int i=s;i<e;i++){cin>>arr[i];}
#define v(type) vector<type>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define maxI(x) max_element(all(x))-x.begin()
#define minI(x) min_element(all(x))-x.begin()
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define sci(x) int x; cin>>x
#define scl(x) ll x; cin>>x
#define scii(x,y) int x,y; cin>>x>>y
#define scll(x,y) ll x,y; cin>>x>>y
#define sciii(x,y,z) int x,y,z; cin>>x>>y>>z
#define sclll(x,y,z) ll x,y,z; cin>>x>>y>>z
#define scStr(x) string x; cin >> x
#define scStrr(x, y) string x, y; cin >> x >> y
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

#define pbds tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;

string to_string(char s)
{   string res="'''";res[1]=s;return res; }
string to_string(string s)
{   return '"'+s+'"'; }
string to_string(const char* s)
{return to_string((string)s); }
string to_string(bool b)
{   return (b?"true":"false"); }
template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
template<typename A>
string to_string(A v)
{
    bool first=1; 
    string res="{";
    for(const auto &x:v){
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}
#ifndef ONLINE_JUDGE 
#define db(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else 
#define db(...) 42
#endif


const ll Mod = 1e9+7;
ll bpow(ll n, ll k){
    if(k == 0){
        return 1;
    }
    int rec = bpow( (n*(ll)n)%Mod , k/(ll)2)%Mod;
    if(k%2) return (rec *(ll) n ) % Mod;
    else return rec;
}
template <int mod>
struct ModInt {
    ll x;
    ModInt() : x(0ll) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return bpow(x, mod - 2); }
    friend ostream& operator<<(ostream& s, ModInt<mod> a){ s << a.x; return s; }
    friend istream& operator>>(istream& s, ModInt<mod>& a){ s >> a.x; return s; }
};
using mint = ModInt<Mod>;

v(mint) ansa;
map<int,mint> h;

void compute(){
    // hlpArr.eb(0);
    mint len = 1;
    h[0] += 1;
    mint temp2 = 0;
    for(ll i=0;i<200001;i++){
        // db(i,h,ansa,len);
        // ll temp = 0;
        mint temp = h[9];
        // if(h[9] != 0){
        // len = len == 1 and h[9] != 0 ? len*(2ll) : len + temp2*(2ll);
        len += h[9];
        mint temp2 = h[0];
        h[0] = h[9];
        // h[1] = temp + temp2;
        // ll temp = h[0];
        // temp2 = h[1];
        // h[1] = temp;
        for(int j=1;j<=9;j++){
            mint temp3 = h[j];
            h[j] = temp2;
            temp2 = temp3;
            if(j == 1){
                h[1] += temp;
            }
            // if(h[j] != 9){
            //     hlpArr[j] = 0;
            //     hlpArr.eb(1);
            // }else{
            //     hlpArr[j]++;
            // }
        }
        temp2 = h[9];
        // }
        ansa.eb(len);
    }
}

void solve(){
    scll(n,m);
    mint ans = 0;
    string str = to_string(n);
    f(i,sz(str)){
        ans += ansa[(ll)m + (ll)((int(str[i]) - '0')) - 1ll];
    }
    cout<<ans;
}

int main(){
    ios
    int t;
    cin>>t;
    compute();
    // cout<<"AAAA"<<endl;
    while(t--){
        solve();
        cout<<endl;
    }
}