import java.io.IOException;
import java.util.List;

public class Stress {
    public void run() throws IOException {
        int total = 9;
        int colors = 5;

        int[] powers = new int[total + 1];
        powers[0] = 1;
        for (int i = 1; i <= total; i++) {
            powers[i] = powers[i - 1] * colors;
        }

        for (int n = 1; n <= total; n++) {
            int[] board = new int[n];
            for (int p = 1; p + n <= total; p++) {
                int[] players = new int[p];
                System.out.format("n = %d, p = %d%n", n, p);
                for (int bc = 0; bc < powers[n]; bc++) {
                    for (int i = 0; i < n; i++) {
                        board[i] = bc / powers[i] % colors;
                    }
                    for (int pc = 0; pc < powers[p]; pc++) {
                        for (int i = 0; i < p; i++) {
                            players[i] = pc / powers[i] % colors;
                        }
                    }
                    for (int h = 0; h < colors; h++) {
                        List<Integer> reference = new kabaleo_gk().solve(colors, h, board, players);
//                        stress(colors, h, board, players, reference, new kabaleo_gk_ok_cases().solve(colors, h, board, players));
//                        stress(colors, h, board, players, reference, kabaleo_keka_stress.solve(n, p, colors, h, board, players));
                        stress(colors, h, board, players, reference, kabaleo_keka_wa_stress.solve(n, p, colors, h, board, players));
//                        stress(colors, h, board, players, reference, new kabaleo_re_stress().solve(n, p, colors, h, board, players));
//                        stress(colors, h, board, players, reference, new Kabaleo_stress().solve(n, p, colors, h, board, players));
//                        stress(colors, h, board, players, reference, kabaleo_t4_stress.solve(n, p, colors, h, board, players));
                    }
                }
            }
        }
    }

    private void stress(int colors, int h, int[] board, int[] players, List<Integer> reference, List<Integer> kabaleo_gk_ok) {
        if (!reference.equals(kabaleo_gk_ok)) {
            System.out.format("%d %d %d %d%n", board.length, players.length, colors, h + 1);
            for (int i : board) {
                System.out.print(i + 1 + " ");
            }
            System.out.println();
            for (int i : players) {
                System.out.print(i + 1 + " ");
            }
            System.out.println();
            System.out.println();
        }
    }

    public static void main(String[] args) throws IOException {
        new Stress().run();
    }
}
