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;
	}
}
package RecycledNumbers;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Hashtable;

import DancingWithGooglers.Googler;



public class MainProcess {

	/**
	 * @param args
	 */
	
	private int A ;
	private int B ;
	
	public MainProcess(File f){
		readFile(f);
		
	}
	
	private void readFile(File f){
		
		int numCase = 0;
		
		try {
			FileReader fr = new FileReader(f);
			BufferedReader br = new BufferedReader(fr);
			
			String str = "";
			
			if( (str = br.readLine())!=null){
				numCase = Integer.parseInt(str);
			}
			
			int count = 0;
			while( count < numCase){
				str = br.readLine();
				String[] substr = str.split(" ");
				A = Integer.parseInt(substr[0]); 
				B = Integer.parseInt(substr[1]); 
				
				findAns(count ,substr[0].length());
				count++;
			}
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	private void findAns(int count , int numDigit){
		
		int totalPair=0;
		
		if(numDigit<=1){
			System.out.println("Case #" + (count+1) + ": 0");
		}
		else{
			
			for(int i=A ; i<=B ; i++){
				totalPair += findPair(i , numDigit);
			}
			
			System.out.println("Case #" + (count+1) + ": " + totalPair);
		}
	}
	
	private int findPair(int number , int numDigit){
		Hashtable<Integer , Boolean> usedTable = new Hashtable<Integer , Boolean>();
		
		int numPair =0;
		
		for(int i=1 ; i<numDigit ; i++ ){
			int base = getPower(i);
			int secondPart = number % base;
			int firstPart = (number - secondPart) / base;
			
			int newNumber = secondPart*getPower(numDigit - i) + firstPart;
			
			if(newNumber<=B && newNumber > number){
				if(!usedTable.containsKey(newNumber)){
					numPair++;
					usedTable.put(newNumber, true);
				}

			}
		}
		
		return numPair;
	}
	
	private int getPower(int n){
		int number = 1;
		
		if(n==0) return number;
		else{
			for(int i=0 ; i< n ; i++){
				number *=10;
			}
			
			return number;
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		File f = new File(".\\src\\RecycledNumbers\\C-small-attempt0.in");
		MainProcess m = new MainProcess(f);
	}

}
