#include <bits/stdc++.h>
using namespace std;

#define LL long long int
#define LD long double
#define inp_s ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define MOD 1000000007
#define INF 1000000000
#define pii pair<int, int>

// natural, no 9, and not divisible by 9

vector<int> v;

LL DP[20][3][10];

void reset(){
      for(int i=0 ; i<20 ; i++){
            for(int j=0 ; j<3 ; j++){
                  for(int k=0 ; k<10 ; k++){
                        DP[i][j][k] = -1;
                  }
            }
      }
}

LL compute(int pos, int f, int mod){
      if(pos == v.size()){
            if(mod != 0) return 1LL;
            return 0LL;
      }     
      if(DP[pos][f][mod] != -1) return DP[pos][f][mod];
      
      LL ans = 0;
      
      int rng = (f == 1) ? 8 : v[pos];
      
      for(int d=0 ; d<=rng ; d++){
            int n_f = (f | (d < v[pos]));
            int n_mod = (mod * 10 + d) % 9;
            ans += compute(pos+1, n_f, n_mod);
      }
      return (DP[pos][f][mod] = ans);
}


LL solve(LL x){
      if(x <= 0) return 0;
      v.clear();
      while(x > 0){
            int rem = x % 10;
            v.push_back(rem);
            x = x / 10;
      }
      reverse(v.begin(), v.end());
      reset();
      LL ans = compute(0, 0, 0);
      return ans;
}

int main(){
      int T;
      cin >> T;
      for(int t=1 ; t<=T ; t++){
            LL l, r;
            cin >> l >> r;
            LL ans = solve(r) - solve(l-1);
            cout << "Case #" << t << ": " << ans << '\n';
      }
      return 0;
}