#include<bits/stdc++.h>
#include<iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ar array
#define all(a) a.begin(),a.end()
#define Unique(a) a.erase(unique(all(a)), a.end())
#define mod 998244353
#define ld long double
#define endl "\n"
#define wh(x) cerr<< #x << " is " << x << '\n';
#define pb push_back
#define mxn 2005
#define fi first
#define se second
#define inf 1e9
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ord_set;
ll dp[20][10];
ll calc(int ind,int re,string s){
if(ind>s.length())
return 1;
int li;
ll ans=dp[ind][re];
if(ans>=0)
return ans;
ans=0;
if(re){
li=s[ind-1]-'0';
if(ind&1){
for(int i=0;i<=li;i++){
if(i&1){
if(i<li)
ans+=calc(ind+1,0,s);
else
ans+=calc(ind+1,1,s);
}
}
}
else{
for(int i=0;i<=li;i++){
if(i%2==0){
if(i<li)
ans+=calc(ind+1,0,s);
else
ans+=calc(ind+1,1,s);
}
}
}
}
else{
li=9;
if(ind&1){
for(int i=0;i<=li;i++){
if(i&1)
ans+=calc(ind+1,0,s);
}
}
else{
for(int i=0;i<=li;i++){
if(i%2==0)
ans+=calc(ind+1,0,s);
}
}
}
return dp[ind][re]=ans;
}
ll solve(){
string l,r;
cin>>l>>r;
ll l1=0;
for(int i=0;i<l.length();i++)
l1*=10,l1+=l[i]-'0';
--l1;
string nl=to_string(l1);
ll a=0,b=0;
memset(dp,-1,sizeof dp);
for(int i=0;i<nl.length();i++)
a+=calc(i+1,i==0,nl);
memset(dp,-1,sizeof dp);
for(int i=0;i<r.length();i++)
b+=calc(i+1,i==0,r);
return b-a;
}
int main(void){
fast;
int t;
cin>>t;
for(int i=1;i<=t;i++)
cout<<"Case #"<<i<<": "<<solve()<<endl;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGU8aW9tYW5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