#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;
}
