// “Success is not final; failure is not fatal; it is the courage to continue that counts.” – Winston Churchill. ...

#include<bits/stdc++.h>
using namespace std;
#define dhiraj ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define endl "\n"
#define test int t;cin>>t;while(t--)
#define pie 3.1415926536
#define onecount(n) __builtin_popcount(n)
#define leadingzeros(n) __builtin_clzint(n)
#define lb(v,x) lower_bound(v.begin(), v.end(), x)
#define ub(v,x) upper_bound(v.begin(), v.end(), x)
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define MOD 1000000007
#warning Check Divide by zero
#warning Check Array size
#warning Check Base Case
typedef vector<int>vi;
typedef pair<int,int>pii;
typedef vector<pair<int,int>>vii;
typedef map<int,int>mi;
struct abc{int z,y,x,ans;};
bool compare(abc a1,abc a2){if(a1.x==a2.x)return a1.y<a2.y;return a1.x<a2.x;}
bool sortindex(abc a1,abc a2){return a1.z<a2.z;}
bool isprime(int n){for(int i=2;i<=sqrt(n);i++)if(n%i==0)return false;return true;}
int countDivisors(int n){int cnt=0;for(int i=1;i<=sqrt(n);i++){if(n%i==0){if(n/i == i)cnt++;else cnt+=2;}}return cnt;}
int addMOD(int x,int y){return (x+y)%MOD;}
int mulMOD(int x,int y){return (x*y)%MOD;}
int subMOD(int x,int y){return (x-y+MOD)%MOD;}
int lcm(int a,int b){return (a*b)/__gcd(a,b);}
int fact[3000007] = {0};
void facto(){fact[0]=1;fact[1]=1;for(int i=2;i<3000007;i++)fact[i]=(fact[i-1]*i)%MOD;}
int fpow(int x, int y,int p=MOD){x=x%p;int sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
int ncr(int n, int r) {if(r>n)return 0;int res=1;res=fact[n];res=(res*(fpow(fact[r],MOD-2)))%MOD;res=(res*(fpow(fact[n-r],MOD-2)))%MOD;return res;}
int npr(int n,int r){if(r>n)return 0;int res=1;res=fact[n];res=(res*(fpow(fact[n-r],MOD-2)))%MOD;return res;}
int bit[200005];
void update_bit(int i,int x){i++;for(;i<=2e5;i+=i&-i)bit[i]+=x;}
int query_bit(int i){int r=0;i++;for(;i;i-=i&-i)r+=bit[i];return r;}
int getmin(int a[],int b[],int i,int j,int l,int r,int pos){if(l<=i && r>=j)return b[pos];if(j<l || i>r)return 1e9;int m=(i+j)/2;return min(getmin(a,b,i,m,l,r,2*pos+1),getmin(a,b,m+1,j,l,r,2*pos+2));}
int construct_min(int a[],int b[],int l,int r,int pos){if(l==r){b[pos]=a[l];return a[l];}int m=(l+r)/2;b[pos]=min(construct_min(a,b,l,m,pos*2+1),construct_min(a,b,m+1,r,pos*2+2));return b[pos];}
void updatesegment_min(int a[],int b[],int i,int j,int ind,int val,int node){if(i==j){a[ind]=val;b[node]=val;}else{int mid=(i+j)/2;if(ind>=i && ind<=mid)updatesegment_min(a,b,i,mid,ind,val,2*node+1);else updatesegment_min(a,b,mid+1,j,ind,val,2*node+2);b[node]=min(b[2*node+1],b[node*2+2]);}return;}
int getmax(int a[],int b[],int i,int j,int l,int r,int pos){if(l<=i && r>=j)return b[pos];if(j<l || i>r)return 0;int m=(i+j)/2;return max(getmax(a,b,i,m,l,r,2*pos+1),getmax(a,b,m+1,j,l,r,2*pos+2));}
int construct_max(int a[],int b[],int l,int r,int pos){if(l==r){b[pos]=a[l];return a[l];}int m=(l+r)/2;b[pos]=max(construct_max(a,b,l,m,pos*2+1),construct_max(a,b,m+1,r,pos*2+2));return b[pos];}
void updatesegment_max(int a[],int b[],int i,int j,int ind,int val,int node){if(i==j){a[ind]=val;b[node]=val;}else{int mid=(i+j)/2;if(ind>=i && ind<=mid)updatesegment_max(a,b,i,mid,ind,val,2*node+1);else updatesegment_max(a,b,mid+1,j,ind,val,2*node+2);b[node]=max(b[2*node+1],b[node*2+2]);}return;}
int binary_exponention(int a,int b){int res=1;while(b>0){if(b&1)res=res*a;a=a*a;b>>=1;}return res;}
int n,m,k,l,r,x,y,z,p,q,res,ans,t;
const int mod=1e9+7;
int dp[200005];
void solve(){
        cin>>n>>m;
        int ans=0;
        while(n){
                int x=n%10;
                ans+=dp[m+x];
                ans%=mod;
                n/=10;
        }
        cout<<ans<<endl;
}
int32_t main(){
        dhiraj;
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
        // facto();
        for(int i=0;i<10;i++)dp[i]=1;
        for(int i=10;i<2e5+5;i++)dp[i]=(dp[i-9]+dp[i-10])%mod;
        test
        solve();
}