下面是代码
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod =1e9+7;
const int N =100;
int dp[N][N],a[N],ll,rr,pos,tot;
int dfs(int pos, int sum, bool top)
{
if (!pos) return sum%mod;
if (!top&&~dp[pos][sum]) return dp[pos][sum]%mod;
int tmp=top ? a[pos] : 9;
int ans=0;
for (int i=0; i<=tmp; i++)
{
ans+=dfs(pos-1,sum+i,top&&i==tmp)%mod;
}
if (!top) dp[pos][sum]=ans;
return ans%mod;
}
int solve (int x)
{
tot=0;
while (x)
{
a[++tot]=x%10;
x/=10;
}
return (dfs(tot,0,1));
}
signed main()
{
int t;
cin >> t;
while (t--)
{
memset(dp,-1,sizeof(dp));
cin >> ll >> rr;
cout << (solve(rr)-solve(ll-1))%mod << endl;
}
}