public class AllCombinations2 {
	
	public static void main(String args[]) {
		new AllCombinations2() ;
	}

	int count=1;
	
	public AllCombinations2() {
		first (1, 2, 3, 4, 5);
	}

	public void first (int a, int b, int c, int d, int e) {
		second (a, b, c, d, e);
		second (b, c, d, e, a);
		second (c, d, e, a, b);
		second (d, e, a, b, c);
		second (e, a, b, c, d);
	}

	public void second (int f, int g, int h, int i, int j) {
		third (f, g, h, i, j);
		third (f, h, i, j, g);
		third (f, i, j, g, h);
		third (f, j, g, h, i);
	}

	public void third (int k, int l, int m, int n, int o) {
		fourth (k, l, m, n, o);
		fourth (k, l, n, o, m);
		fourth (k, l, o, m, n);
	}

	public void fourth (int p, int q, int r, int s, int t) {
		System.out.println(count+". "+p+""+q+""+r+""+s+""+t);
		count++;
		System.out.println(count+". "+p+""+q+""+r+""+t+""+s);
		count++;
	}

}
