//a+b = (a^b) + 2*(a&b)
//b^c = (a^b)^(a^c) 
//gcd(x,y) = gcd(x-y,y)
//if n = 5000 then complexity cannot be (n^2*log(n)) means no map ,no sets
//check for long long overflow if input is large
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define mod 1000000007
//#define mod 998244353
#define pb push_back
#define ll long long
#define fi first
#define se second
#define vi vector<int> 
#define pii pair<int,int>
#define mii map<int,int>
#define loop(i,n) for(int i=0;i<n;i++) 
#define pp  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) 
#define fill(a,b) memset(a, b, sizeof(a))
#define all(x) (x).begin(), (x).end()
 
#define en cout<<"\n"

#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
const long long INF = 2000000000000000000;

long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans; 
}
int dp[200025]={0};
void solve()
{
	int n, m;
	cin >> n >> m;
	int ans=0;
	while(n)
	{
		int temp = m;
		int x = n%10;
		n/=10;
//		trace(x);
		if(temp < 10 - x)
		{
			ans++;
			ans%=mod;
		}
		else
		{
			temp-= (10-x);
			ans+=dp[temp];
			ans%=mod;
		}
	}
	cout<<(ans+mod)%mod;
}
int32_t main() 
{
pp;
int test=1;
vi mp(11,0);
mp[1]=1;
mp[0]=1;
int sum = 0, pre, pre1;
dp[0]=2;
for(int i=1;i<=200013;i++)
{
		pre = mp[0], 
		sum = mp[9];
		for(int j=1;j<= 9;j++){
			pre1 = mp[j];
	    	mp[j] = pre;
	    	pre = pre1;
		}
		mp[0] = 0;
		mp[1] += sum;
		mp[0] += sum;
		for(int j=0;j<=9;j++)
		{
			dp[i] += mp[j];
			dp[i]%=mod;
		}
//	trace2(i,dp[i]);
}
cin>>test;
while(test--)
{
	solve();
	en;
}
return 0 ;
}