#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
static char buf[1048576];
static int s = 1048576;
static int e = 1048576;
if(s == e && e == 1048576){
e = fread_unlocked(buf, 1, 1048576, stdin);
s = 0;
}
if(s == e){
return EOF;
}
return buf[s++];
}
inline void rd(int &x){
int k;
int m=0;
x=0;
for(;;){
k = my_getchar_unlocked();
if(k=='-'){
m=1;
break;
}
if('0'<=k&&k<='9'){
x=k-'0';
break;
}
}
for(;;){
k = my_getchar_unlocked();
if(k<'0'||k>'9'){
break;
}
x=x*10+k-'0';
}
if(m){
x=-x;
}
}
inline void rd(long long &x){
int k;
int m=0;
x=0;
for(;;){
k = my_getchar_unlocked();
if(k=='-'){
m=1;
break;
}
if('0'<=k&&k<='9'){
x=k-'0';
break;
}
}
for(;;){
k = my_getchar_unlocked();
if(k<'0'||k>'9'){
break;
}
x=x*10+k-'0';
}
if(m){
x=-x;
}
}
inline int rd_int(void){
int x;
rd(x);
return x;
}
struct MY_WRITER{
char buf[1048576];
int s;
int e;
MY_WRITER(){
s = 0;
e = 1048576;
}
~MY_WRITER(){
if(s){
fwrite_unlocked(buf, 1, s, stdout);
}
}
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
MY_WRITER_VAR.s = 0;
}
MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
my_putchar_unlocked(a);
}
inline void wt_L(int x){
int s=0;
int m=0;
char f[10];
if(x<0){
m=1;
x=-x;
}
while(x){
f[s++]=x%10;
x/=10;
}
if(!s){
f[s++]=0;
}
if(m){
my_putchar_unlocked('-');
}
while(s--){
my_putchar_unlocked(f[s]+'0');
}
}
inline void wt_L(unsigned x){
int s=0;
char f[10];
while(x){
f[s++]=x%10;
x/=10;
}
if(!s){
f[s++]=0;
}
while(s--){
my_putchar_unlocked(f[s]+'0');
}
}
inline void wt_L(long long x){
int s=0;
int m=0;
char f[20];
if(x<0){
m=1;
x=-x;
}
while(x){
f[s++]=x%10;
x/=10;
}
if(!s){
f[s++]=0;
}
if(m){
my_putchar_unlocked('-');
}
while(s--){
my_putchar_unlocked(f[s]+'0');
}
}
inline void wt_L(unsigned long long x){
int s=0;
char f[21];
while(x){
f[s++]=x%10;
x/=10;
}
if(!s){
f[s++]=0;
}
while(s--){
my_putchar_unlocked(f[s]+'0');
}
}
int WRITER_DOUBLE_DIGIT = 15;
inline int writerDigit_double(){
return WRITER_DOUBLE_DIGIT;
}
inline void writerDigit_double(int d){
WRITER_DOUBLE_DIGIT = d;
}
inline void wt_L(double x){
const int d = WRITER_DOUBLE_DIGIT;
int k;
int r;
double v;
if(x!=x || (x==x+1 && x==2*x)){
my_putchar_unlocked('E');
my_putchar_unlocked('r');
my_putchar_unlocked('r');
return;
}
if(x < 0){
my_putchar_unlocked('-');
x = -x;
}
x += 0.5 * pow(0.1, d);
r = 0;
v = 1;
while(x >= 10*v){
v *= 10;
r++;
}
while(r >= 0){
r--;
k = floor(x / v);
if(k >= 10){
k = 9;
}
if(k <= -1){
k = 0;
}
x -= k * v;
v *= 0.1;
my_putchar_unlocked(k + '0');
}
if(d > 0){
my_putchar_unlocked('.');
v = 1;
for(r=(0);r<(d);r++){
v *= 0.1;
k = floor(x / v);
if(k >= 10){
k = 9;
}
if(k <= -1){
k = 0;
}
x -= k * v;
my_putchar_unlocked(k + '0');
}
}
}
inline void wt_L(const char c[]){
int i=0;
for(i=0;c[i]!='\0';i++){
my_putchar_unlocked(c[i]);
}
}
inline void wt_L(string &x){
int i=0;
for(i=0;x[i]!='\0';i++){
my_putchar_unlocked(x[i]);
}
}
template<class T, class S> inline T pow_L(T a, S b){
T res = 1;
res = 1;
for(;;){
if(b&1){
res *= a;
}
b >>= 1;
if(b==0){
break;
}
a *= a;
}
return res;
}
inline double pow_L(double a, double b){
return pow(a,b);
}
int TEST;
int sz;
int d[20];
long long dp[2];
long long nx[2];
long long solve(long long x){
int i, k;
long long res = 0;
if(x==0){
return res;
}
sz = 0;
while(x){
d[sz++] = x%10;
x/=10;
}
reverse(d, d+sz);
for(i=(1);i<(sz);i++){
res +=(pow_L(5LL,i));
}
{
auto cTE1_r3A = (0);
auto RZTsC2BF = ( 1);
dp[0] = cTE1_r3A;
dp[1] = RZTsC2BF;
}
for(k=(0);k<(sz);k++){
{
auto WYIGIcGE = (0);
auto t_ynMSdg = ( 0);
nx[0] = WYIGIcGE;
nx[1] = t_ynMSdg;
}
for(i=((k+1)%2);i<(10);i+=(2)){
nx[0] += dp[0];
if(i < d[k]){
nx[0] += dp[1];
}
if(i==d[k]){
nx[1] += dp[1];
}
}
{
auto tU__gIr_ = (nx[0]);
auto a2conNHc = ( nx[1]);
dp[0] = tU__gIr_;
dp[1] = a2conNHc;
}
}
return res + dp[0] + dp[1];
}
int main(){
int hCmBdyQB = rd_int();
for(TEST=(0);TEST<(hCmBdyQB);TEST++){
long long L;
rd(L);
long long R;
rd(R);
wt_L("Case #");
wt_L(TEST+1);
wt_L(": ");
wt_L(solve(R) - solve(L-1));
wt_L('\n');
}
return 0;
}
// cLay varsion 20201115-2
// --- original code ---
// int TEST;
//
// int sz, d[20];
// ll dp[2], nx[2];
//
// ll solve(ll x){
// ll res = 0;
// if(x==0) return res;
//
// sz = 0;
// while(x) d[sz++] = x%10, x/=10;
// reverse(d, d+sz);
//
// rep(i,1,sz) res += 5LL ** i;
//
// (dp[0], dp[1]) = (0, 1);
// rep(k,sz){
// (nx[0], nx[1]) = (0, 0);
// rep(i,(k+1)%2,10,2){
// nx[0] += dp[0];
// if(i < d[k]) nx[0] += dp[1];
// if(i==d[k]) nx[1] += dp[1];
// }
// (dp[0], dp[1]) = (nx[0], nx[1]);
// }
//
// return res + dp[0] + dp[1];
// }
//
// {
// REP(TEST,rd_int()){
// ll @L, @R;
// wtF("Case #{TEST+1}: ");
// wt(solve(R) - solve(L-1));
// }
// }