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 CaseSolvers;

import Controller.IO;

public class RecycledNumbersCase extends CaseSolver {

	public RecycledNumbersCase(int order, int numberOfLines, IO io) {
		super(order, numberOfLines, io);
	}

	int a, b;

	@Override
	public void addLine(String line) {
		String[] str = line.split(" ");
		a = Integer.parseInt(str[0]);
		b = Integer.parseInt(str[1]);
	}

	@Override
	public void printSolution() {
		System.err.println("Case #" + getOrder() + ": " + cont);
	}

	int cont;

	@Override
	public CaseSolver process() {
		for (int m = a; m < b; m++) {
			for (int n = m + 1; n <= b; n++) {
				//System.err.println(m + " e " + n);
				if (isRecycled(m, n)) {
					cont++;
				}
			}
		}

		return this;
	}

	private boolean isRecycled(int m, int n) {
		StringBuilder a = new StringBuilder("" + m);
		String b = "" + n;

		for (int i = 0; i < a.length() - 1; i++) {
			a.insert(0, a.charAt(a.length() - 1)).deleteCharAt(a.length() - 1);
			if (a.toString().equals(b)) {
				return true;
			}
		}

		return false;
	}

	@Override
	public void initializeVars() {
		// TODO Auto-generated method stub

	}

}
