package fixjava;

public class StringUtils {

	/** Repeat the given string the requested number of times. */
	public static String repeat(String str, int numTimes) {
		StringBuilder buf = new StringBuilder(Math.max(0, str.length() * numTimes));
		for (int i = 0; i < numTimes; i++)
			buf.append(str);
		return buf.toString();
	}

	/**
	 * Pad the left hand side of a field with the given character. Always adds at least one pad character. If the length of str is
	 * greater than numPlaces-1, then the output string will be longer than numPlaces.
	 */
	public static String padLeft(String str, char padChar, int numPlaces) {
		int bufSize = Math.max(numPlaces, str.length() + 1);
		StringBuilder buf = new StringBuilder(Math.max(numPlaces, str.length() + 1));
		buf.append(padChar);
		for (int i = 1, mi = bufSize - str.length(); i < mi; i++)
			buf.append(padChar);
		buf.append(str);
		return buf.toString();
	}

	/**
	 * Pad the right hand side of a field with the given character. Always adds at least one pad character. If the length of str is
	 * greater than numPlaces-1, then the output string will be longer than numPlaces.
	 */
	public static String padRight(String str, char padChar, int numPlaces) {
		int bufSize = Math.max(numPlaces, str.length() + 1);
		StringBuilder buf = new StringBuilder(Math.max(numPlaces, str.length() + 1));
		buf.append(str);
		buf.append(padChar);
		while (buf.length() < bufSize)
			buf.append(padChar);
		return buf.toString();
	}

	/** Intern all strings in an array, skipping null elements. */
	public static String[] intern(String[] arr) {
		for (int i = 0; i < arr.length; i++)
			arr[i] = arr[i].intern();
		return arr;
	}

	/** Intern a string, ignoring null */
	public static String intern(String str) {
		return str == null ? null : str.intern();
	}

}

import java.util.*;
import static java.lang.System.*;

class C{

    static public void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int cases = Integer.parseInt(sc.nextLine());
	for(int c = 1; c<=cases; c++){
	    String[] s = sc.nextLine().split(" ");
	    int a = Integer.parseInt(s[0]);
	    int b = Integer.parseInt(s[1]);
	    int l = s[0].length();
	    long cnt = 0;
	    for(int i = a; i<b; i++){
		HashSet<Integer> set = new HashSet<Integer>();
		for(int pos = 1; pos<l; pos++){
		    int k = (int)Math.pow(10,pos);
		    int kk = (int)Math.pow(10,l-pos);
		    int front = i/k;
		    int back = i-front*k;
		    int newn = back*kk+front;
		    if(newn>i && newn<=b){
			set.add(newn);
		    }
		}
		cnt+=set.size();
	    }
	    out.println("Case #"+c+": "+cnt);
	}
    }
}