import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.*;

/**
 * To be documented
 *
 * @author Pavel Mavrin
 */
public class gen_tree {

    void printTest(List<Actor> actors, List<Scene> scenes) throws FileNotFoundException {
        PrintWriter out = new PrintWriter(System.out);
        out.print(actors.size() + " " + scenes.size());
        out.print("\n");
        for (Scene scene : scenes) {
            out.print(scene.actors.size());
            for (Actor actor : scene.actors) {
                out.print(" " + actor.id);
            }
            out.print("\n");
        }
        out.close();
    }

    Random random = new Random(1242357568767896534L);

    void printTree(int n, int m, int nm) throws FileNotFoundException {
        Node root = new Node();
        root.weight = n;
        List<Node> internal = new ArrayList<Node>();
        List<Node> leaves = new ArrayList<Node>();
        leaves.add(root);
        int rem = nm;
        while (rem > n - leaves.size() && leaves.size() < n) {
            // pick random leave >1
            int i;
            do {
                i = random.nextInt(leaves.size());
            } while (leaves.get(i).weight == 1);
            Node leaf = leaves.get(i);
            // split
            int k = random.nextInt(leaf.weight - 1) + 1;
            if (rem - k >= n - leaves.size() - 1) {
                leaf.children[0] = new Node();
                leaf.children[1] = new Node();
                internal.add(leaf);
                leaf.children[0].weight = leaf.weight - k;
                leaf.children[1].weight = k;
                leaves.set(i, leaf.children[0]);
                leaves.add(leaf.children[1]);
                rem -= k;
            }
        }
        for (Node node : leaves) {
            while (node.weight > 1) {
                node.children[0] = new Node();
                node.children[1] = new Node();
                internal.add(node);
                node.children[0].weight = node.weight - 1;
                node.children[1].weight = 1;
                node = node.children[0];
                rem--;
            }
        }
        if (rem < 0) throw new RuntimeException();
        root.calcHeight();
        if (m < root.height) {
            throw new RuntimeException("m is less rootHeight");
        }
        root.assignStages(1, m);
        boolean[] z = new boolean[m + 1];
        for (Node node : internal) {
            z[node.sceneId] = true;
        }
        int[] p = new int[m + 1];
        int mm = 0;
        for (int i = 0; i <= m; i++) {
            if (z[i]) {
                p[i] = mm++;
            }
        }

        for (Node node : internal) {
            node.sceneId = p[node.sceneId];
        }
//        int mm = m;
        List<Actor> actors = new ArrayList<Actor>();
        for (int i = 0; i < n; i++) actors.add(new Actor(i + 1));
        List<Scene> scenes = new ArrayList<Scene>();
        for (int i = 0; i < mm; i++) scenes.add(new Scene());

        Collections.shuffle(actors, random);
        root.fillScenes(scenes, actors, 0, n);

        for (Scene scene : scenes) {
            Collections.sort(scene.actors);
        }

        printTest(actors, scenes);

    }

    class Node {
        Node[] children = new Node[2];
        int weight;
        int height;
        int sceneId;

        public void calcHeight() {
            height = 0;
            for (int i = 0; i < 2; i++) {
                Node child = children[i];
                if (child != null) {
                    child.calcHeight();
                    height = Math.max(height, child.height + 1);
                }
            }
        }

        public void assignStages(int l, int r) {
            if (height == 0) return;
            if (sceneId == 0) {
                int n = r - l + 1;
                boolean[] z = new boolean[n];
                if (height > n) throw new RuntimeException();
                for (int i = 0; i < height; i++) {
                    int j;
                    do {
                        j = random.nextInt(n);
                    } while (z[j]);
                    z[j] = true;
                }
                int j = 0;
                Node cur = this;
                for (int i = 0; i < height; i++) {
                    while (!z[j]) j++;
                    cur.sceneId = l + j;
                    if (i < height - 1) {
                        j++;
                        if (cur.children[0].height > cur.children[1].height) {
                            cur = cur.children[0];
                        } else {
                            cur = cur.children[1];
                        }
                    }
                }
            }
            for (int i = 0; i < 2; i++) {
                if (children[i] != null) {
                    children[i].assignStages(sceneId + 1, r);
                }
            }
        }

        public void fillScenes(List<Scene> scenes, List<Actor> actors, int l, int r) {
            if (height > 0) {
                Scene scene = scenes.get(sceneId);
                int m = l + (children[0].weight);
                for (int i = m; i < r; i++) {
                    scene.actors.add(actors.get(i));
                }
                children[0].fillScenes(scenes, actors, l, m);
                children[1].fillScenes(scenes, actors, m, r);
            }
        }
    }

    class Actor implements Comparable<Actor> {
        int id;

        public Actor(int id) {
            this.id = id;
        }

        public int compareTo(Actor actor) {
            return id - actor.id;
        }
    }

    class Scene {
        List<Actor> actors = new ArrayList<Actor>();
    }

    public static void main(String[] args) throws FileNotFoundException {
        int n = Integer.parseInt(args[0]);
        int m = Integer.parseInt(args[1]);
        int k = Integer.parseInt(args[2]);
        new gen_tree().printTree(n, m, k);
    }

}
