import java.io.*;

class code1
{
	public static void main(String args[]) throws Exception 
	{
		File ii = new File ("C-small-attempt1.in");
		FileInputStream fis = new FileInputStream(ii);
		BufferedReader  br = new BufferedReader(new InputStreamReader (fis));
		int cases = Integer.parseInt(br.readLine());
		FileOutputStream fout = new FileOutputStream ("output.txt");
		DataOutputStream dout = new DataOutputStream (fout);
		int total=0;
		for(int i=0;i<cases;i++){
		String temp = br.readLine();
		String parts [] = temp.split(" ");
		int lower = Integer.parseInt(parts[0]);
		int upper = Integer.parseInt(parts[1]);
		System.out.println(lower+" "+upper);
		
		for(int j=lower;j<=upper;j++)
		{
			int abc = j;int length=0;
			if(j<10)continue;
			while (abc!=0){abc/=10;length++;}
			abc=j;
			for(int m=0;m<length-1;m++){
				int shift = abc%10;
				abc=abc/10;
				System.out.println("hi "+j);
				abc=abc+shift*power(10,length-1);
				if(abc<=upper&&shift!=0&&abc>j)total++;
				System.out.println(total);
			}
		}
 		dout.writeBytes("Case #"+(i+1)+ ": "+total+"\n");
 		total=0;
		}//for close
		
	}

	private static int power(int i, int j) {
		int no=1;
		for(int a=0;a<j;a++){no=10*no;}
		return no;
	}
}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;

public class Recycle {

    public static void main(String[] args) {
        if (args.length == 1) {
            String file = args[0];
            try {
                BufferedReader br = new BufferedReader(new FileReader(file));
                PrintWriter pw = new PrintWriter(new FileWriter("output.out", false));
                int count = Byte.parseByte(br.readLine());
                String line;
                int i = 0;
                while ((line = br.readLine()) != null && (i++ < count)) {
                    int i2 = Integer.parseInt(line.substring(line.lastIndexOf(" ") + 1));
                    int i1 = Integer.parseInt(line.substring(0, line.lastIndexOf(" ")));
                    int s = sendMeRange(i1, i2);
                    pw.println("Case #" + i + ": " + s);
                }
                br.close();
                pw.close();
            } catch (Exception err) {
                System.out.println("An error occurred running the program\n" + err);
            }
        } else {
            System.out.println("Please use the input file as one of the parameters");
        }

    }

    public static int sendMeRange(int i1, int i2) {
        byte len = (byte) ("" + i1).length();
        if ( len == 1){
            return 0;
        }
        else{
            String arr[][] = new String[(i2-i1)+1][2];
            int counter=0;
            for (int u = i1; u <= i2; u++){
                String tag = "" + u;
                String reverse = "";
                for (int q = tag.length() - 1; q > -1; q--){
                    reverse += "" + tag.charAt(0);
                }
                if (! tag.equals(reverse)){
                    arr[counter][0] =tag;
                    arr[counter][1] =tag + tag;
                } else{
                    arr[counter][0] =tag;
                    arr[counter][1] ="NOPE";
                }
                counter++;
            }
            counter=0;
            for (int u = 0; u < arr.length; u++){
                for (int u2 = u+1; u2 < arr.length; u2++){
                    if (arr[u][1].contains("" + arr[u2][0])){
                        counter++;
                    }
                }
            }
            return counter;
        }
    }
}