Problem: Recently Pashmak has been employed in a transportation company. The company has k buses and has a contract with a school which has n students. The school planned to take the students to d different places for d days (each day in one place). Each day the company provides all the buses for the trip. Pashmak has to arrange the students in the buses. He wants to arrange the students in a way that no two students become close friends. In his ridiculous idea, two students will become close friends if and only if they are in the same buses for all d days.

Please help Pashmak with his weird idea. Assume that each bus has an unlimited capacity.

Input

The first line of input contains three space-separated integers n, k, d (1 ≤ n, d ≤ 1000; 1 ≤ k ≤ 109).

Output

If there is no valid arrangement just print -1. Otherwise print d lines, in each of them print n integers. The j-th integer of the i-th line shows which bus the j-th student has to take on the i-th day. You can assume that the buses are numbered from 1 to k.

Examples

Input

3 2 2


Output

1 1 2 
1 2 1 


Input

3 2 1


Output

-1

Note

Note that two students become close friends only if they share a bus each day. But the bus they share can differ from day to day.

Solution (in JAVA):

Solution:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.text.*;

public class cf459c {

    static BufferedReader br;
    static Scanner sc;
    static PrintWriter OUT_;
    static StringBuilder BUFFER_OUT = new StringBuilder();

    public static void initA() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            sc = new Scanner(System.in);
            OUT_ = new PrintWriter(System.out);
        } catch (Exception e) {
        }
    }

    static boolean next_permutation(Integer[] p) {
        for (int a = p.length - 2; a >= 0; --a) {
            if (p[a] < p[a + 1]) {
                for (int b = p.length - 1;; --b) {
                    if (p[b] > p[a]) {
                        int t = p[a];
                        p[a] = p[b];
                        p[b] = t;
                        for (++a, b = p.length - 1; a < b; ++a, --b) {
                            t = p[a];
                            p[a] = p[b];
                            p[b] = t;
                        }
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Integer temp2[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Integer.parseInt(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static Long[] getLongArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Long temp2[] = new Long[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Long.parseLong(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static String[] getStringArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            String temp2[] = new String[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = (temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static void println(Object a) {
        BUFFER_OUT.append(a + "\n");
        //out.println(a);
    }

    public static void print(Object a) {
        BUFFER_OUT.append(a);
        //out.println(a);
    }

    public static void print(String s, Object... a) {
        BUFFER_OUT.append(String.format(s, a));
        // out.printf(s, a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static double nextDouble() {
        return sc.nextDouble();
    }

    public static void main(String[] ar) {
        initA();
        cf459c c = new cf459c();
        c.solve();
        OUT_.write(BUFFER_OUT.toString());
        OUT_.flush();
    }
    HashSet<Long> sdh = new HashSet<Long>();
    int bth;
    int n, k, d;
    Integer temp[] = new Integer[1000 + 5];
    int kolom_dikerjakan = 0;
    Integer ou[][] = new Integer[1005][1005];

    void dfs(int i, int j, long hash) {

        if (kolom_dikerjakan == n) {
            // print("SELSE");
            return;
        }
        if (j == d) {
            if (!sdh.contains(hash)) {
                Integer tx[] = new Integer[d];
                System.arraycopy(temp, 0, tx, 0, tx.length);


                // print(Arrays.asList(tx) + " KERJAKAN KOLOM "+kolom_dikerjakan);
                for (; kolom_dikerjakan < n;) {
                    for (int x = 0; x < d; x++) {
                        ou[x][kolom_dikerjakan] = tx[x];
                        // print("SET "+x+","+kolom_dikerjakan +" = "+tx[x]);
                    }
                    kolom_dikerjakan++;
                    boolean a = next_permutation(tx);
                    if (!a) {
                        break;
                    }
                }
                sdh.add(hash);
            }
            return;
        }
        if (i > k) {
            return;
        }
        temp[j] = i;
        dfs(i + 1, j + 1, hash * k + i);

        //ambil sama berulang
        dfs(i, j + 1, hash * k + i);

        //ini di bawahnya krn supaya tdk mengganti temp[j] dgn kanannya
        //ambil angka berikut
        dfs(i + 1, j, hash);


    }

    void solve() {
        Integer xx[] = getIntArr();
        n = xx[0];
        k = xx[1];
        d = xx[2];

        if (n > 1 && (k == 1 || (d == 1 && k < n))) {
            println(-1);
            return;
        }
        //n = kolom d = baris
        long st = System.currentTimeMillis();
        bth = n * d;

     
        dfs(1, 0, 0);
        /*
        for (Integer[] x : list_) {
        print(Arrays.asList(x));
        }
        print(sdh);
         */

        if (kolom_dikerjakan != n) {
            println(-1);
            return;
        }
        // print("SELSE DALAM "+(System.currentTimeMillis() - st));
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < n; j++) {
                print(ou[i][j] + " ");
            }
            println("");
        }


    }
}