#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][2];
ll calc(int ind,int re,string s){
if(ind>s.length())
return 1;
int li;//limit of ith digit
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;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGU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