import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

public class Tests {
    Random rnd = new Random(239);
    int MAX_N = 100;
    int MAX_K = 100;
    int MAX = 100;

    int tests = 1;

    public void writeTest(int k, int[] w) {
        try {
            PrintWriter out = tests == -1 ? new PrintWriter(System.out) : new PrintWriter(String.format("%02d", tests++));

            out.println(w.length + " " + k);
            ArrayList<Integer> w2 = new ArrayList<>();
            for (int x : w) {
                w2.add(x);
            }
            Collections.shuffle(w2, rnd);

            for (int i = 0; i < w2.size(); i++) {
                if (i != 0) {
                    out.print(" ");
                }
                out.print(w2.get(i));
            }
            out.println();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public int solve_ok(int k, int[] w) {
        int ans = 0;
        Arrays.sort(w);
        for (int i = 0; i < w.length; i++) {
            int part = i / k;
            ans += w[w.length - i - 1] * (part + 1);
        }

        return ans;
    }

    public int solve_wa(int k, int[] w) {
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for (int i = 0; i < k; i++) {
            pq.add(0);
        }

        int ans = 0;
        Arrays.sort(w);
        for (int i = 0; i < w.length; i++) {
            int x = pq.poll();
            ans += (x + w[i]);
            pq.add(x + w[i]);
        }

        return ans;
    }

    public void stress(int size) {
        int[] w = new int[size];

        while (true) {
            int k = rnd.nextInt(10) + 1;
            for (int i = 0; i < size; i++) {
                w[i] = rnd.nextInt(10000) + 1;
            }
            if (solve_ok(k, w) != solve_wa(k, w)) {
                writeTest(k, w);
                return;
            }
        }
    }

    public void random(int k, int size) {
        int[] w = new int[size];

        for (int i = 0; i < size; i++) {
            w[i] = rnd.nextInt(MAX) + 1;
        }

        writeTest(k, w);
    }

    public void random(int size) {
        random(rnd.nextInt((int) Math.sqrt(size)) + 1, size);
    }

    public void one(int size) {
        random(1, size);
    }

    public void randomMAX() {
        random(MAX_K, MAX_N);
    }

    public void MAX(int k) {
        int[] w = new int[MAX_N];
        Arrays.fill(w, MAX);
        writeTest(k, w);
    }

    public void small() {
        random(1, 1);
    }

    public void sample1() {
        writeTest(3, new int[]{1, 2, 3, 4, 5, 6});
    }

    public void gen(String[] args, int test) {
        tests = test;
        switch (args[0]) {
            case "sample":
                sample1();
                break;
            case "small":
                int seed = Integer.parseInt(args[1]);
                rnd = new Random(seed);
                small();
                break;
            case "one":
                seed = Integer.parseInt(args[1]);
                rnd = new Random(seed);
                one(rnd.nextInt(MAX_N) + 1);
                break;
            case "random":
                int size = Integer.parseInt(args[1]);
                seed = Integer.parseInt(args[2]);
                rnd = new Random(seed);
                random(size);
                break;
            case "randomMAX":
                seed = Integer.parseInt(args[1]);
                rnd = new Random(seed);
                randomMAX();
                break;
            case "MAX":
                int k = Integer.parseInt(args[1]);
                MAX(k);
                break;
            case "randomK":
                size = Integer.parseInt(args[1]);
                k = Integer.parseInt(args[2]);
                seed = Integer.parseInt(args[3]);
                rnd = new Random(seed);
                random(k, size);
                break;
        }
    }

    public void gen() {
        try {
            Scanner in = new Scanner(new File("tests.txt"));
            int test = 1;
            while (in.hasNext()) {
                String line = in.nextLine();
                if (line.length() == 0)
                    break;
                String[] x = line.split(" ");
                gen(Arrays.copyOfRange(x, 1, x.length), test++);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        if (args.length > 0) {
            new Tests().gen(args, -1);
        } else {
            new Tests().gen();
        }
    }
}
