public class Main { public static void main(String[] args) throws Exception { for (char c = 'A'; c <= 'Z'; c++) { System.out.println("A" + c); if (c > 'A') { System.out.println(c + "" + c); for (char c2 = (char) (c - 1); c2 > 'A'; c2--) { System.out.println(c + "" + c2); System.out.println(c2 + "" + c); } System.out.println(c + "A"); } } } }