// jo code dekh raha h mera bhai meri nai ho rhi progress kahi teri bhi na ruk jaye. Koi tareeka ho to madad kere.

#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test int t; cin>>t; while(t--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define f0(i,n) for( ll i = 0; i < ( n ); i ++)
#define f1(i,n) for( ll i = 1; i <= ( n ); i ++)
#define f(i,m,n) for(auto i = ( m ); i <= ( n ); i ++)
#define fr(i,m,n) for( auto i=(m);i>=(n);i--)
#define nl cout<<"\n"
#define  mod 1000000007
#define fir first
#define sec second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(x) ((ll)x.size())
#define mem(a, b) memset(a, b, sizeof(a));
#define make_graph(k) int x,y; f0(i,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define dekh cout<<"dekh"

#define o_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setpll tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
typedef vector<ll> vl;

ll INF=1e18;
;


ll Pow(ll a, ll b, ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll x = a*a;
        x%=m;
        return Pow(x,b/2,m);
    }
    return (a*Pow(a,b-1,m))%m;
}

bool isp(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)return false;
    }
    return true;
}


//============================================================

   //if(n &(n-1)==0) then n is a power of 2
   // LCM is always a multiple of GCD
   // lcm = k * gcd ;
   // a^b=a+b-2*(a&b)

ll dp[200010];
ll solve(ll num){
	if(num<0)
		return 1;
	if(num==0)
		return 2;
	if(dp[num]!=-1)
		return dp[num]%mod;
	 dp[num]=(solve(num-9)%mod+solve(num-10)%mod)%mod;
	 return dp[num]%mod;
}

int main()
{
    fast
    mem(dp,-1);
    dp[0]=2;
    test
    {

        //dp[0]=2;
       string s;
		cin>>s;
		ll  num;
		cin>>num;
		int cnt=0;
		for(ll i=0;i<s.length();i++){
			ll nr=s[i]-'0';
			cnt+=solve(num-(10-nr));
		}
		cout<<cnt%mod;nl;
    }
}





