\(f_{dep,status,limit,still0}\),
It means that there are \ (status \) 0s in the \ (dep \) position, there is no enumeration number limit \ (limit \) , and whether it is always 0 \ (still0 \)
If there is \ (limit \) or \ (still0 \), there is no need to save the answer.
The other is normal routine transfer
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
template <class t> inline void rd(t &s)
{
s=0;
reg char c=getchar();
while(!isdigit(c))
c=getchar();
while(isdigit(c))
s=(s<<3)+(s<<1)+(c^48),c=getchar();
return;
}
int a[101];
int f[101][101];
inline int dfs(int dep,int status,bool limit,bool still0)
{
if(!dep)
return still0?1:status;
if(!limit&&!still0&&~f[dep][status])
return f[dep][status];
reg int maxi=limit?a[dep]:9,res=0;
for(int i=0;i<=maxi;++i)
{
if(still0)
res+=dfs(dep-1,0,limit&&(i==maxi),!i);
else
res+=dfs(dep-1,status+(!i),limit&&(i==maxi),false);
}
if(!limit&&!still0)
f[dep][status]=res;
return res;
}
inline int solve(int x)
{
memset(f,-1,sizeof f);
reg int n=0;
while(x)
a[++n]=x%10,x/=10;
return dfs(n,0,true,true);
}
inline void work()
{
int l,r;cin>>l>>r;
cout<<solve(r)-solve(l-1)<<endl;
return;
}
signed main(void)
{
ios::sync_with_stdio(false);cin.tie(0);
int t;cin>>t;
for(int i=1;i<=t;++i)
cout<<"Case "<<i<<": ",work();
return 0;
}