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:
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class C {
	public C() 
	{
		Scanner s = new Scanner();
	
		long n = s.nextInt();
		long k = s.nextInt();
		long d = s.nextInt();
	
		if (k == 1 && n > 1) {
			System.out.println(-1);
			System.exit(0);
		}
		int[][] ints = new int[(int)n][(int)d];
		for (int i = 0; i < n; i++) {
			//System.out.println(i);
			ints[i] = convertToNBits(i, (int)k,(int) d );
		}
		
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < n; j++) {
				sb.append((ints[j][i] + 1) + " " );
				if (ints[j].length > d) {
					System.out.println(-1);
					System.exit(0);
				}
			}
			sb.append("\n");
			
		}
		System.out.print(sb);
	
	}
	

	//start, an array of integers at each position
		//n the base of the integers.
		//Example   createBigInt({1,1,2}, 3)  returns   22
		//NOTE, the digits in the int[]s are such that lowest "bit"/power is to the left
		public static BigInteger createBigInt(int[] start, int n) {
			BigInteger total = BigInteger.ZERO;
			BigInteger base = BigInteger.valueOf(n);
			for (int i = 0; i < start.length; i++) {
				BigInteger cur = BigInteger.valueOf(start[i]);
				total = total.add(cur.multiply(base.pow(i)));
			}
			
			return total;
		}
		
		public static int[] convertToNBits (BigInteger value, int base, int min_size) {
			ArrayList<Integer> result = new ArrayList<Integer>();
			BigInteger b = BigInteger.valueOf(base);
			while (value.compareTo(BigInteger.ZERO) > 0) {
				BigInteger mod = value.remainder(b);
				result.add((int) mod.longValue());
				value = value.divide(b);
			}
			
			int[] fin = new int[Integer.max(min_size, result.size())];
			int i;
			for (i = 0; i < result.size(); i++) {
				fin[i] = result.get(i);
			}
			for (;i<min_size;i++){//set "leading" zeroes
				fin[i] = 0;
			}
			return fin;
			
		}
		static ArrayList<Integer> result = new ArrayList<Integer>(1000);
		public static int[] convertToNBits (int value, int base, int min_size) {
			
			result.clear();
			while (value > 0) {
				int mod = value % base;
				result.add( mod);
				value /= base;
			}
			
			int[] fin = new int[Integer.max(min_size, result.size())];
			int i;
			for (i = 0; i < result.size(); i++) {
				fin[i] = result.get(i);
			}
			for (;i<min_size;i++){//set "leading" zeroes
				fin[i] = 0;
			}
			return fin;
			
			
		}
	
	public static void main(String[] args) {
		new C();
	}

	public static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(Reader in) {
			br = new BufferedReader(in);
		}

		public Scanner() {
			this(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		// Slightly different from java.util.Scanner.nextLine(),
		// which returns any remaining characters in current line,
		// if any.
		String readNextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		public int[] readNextLineInts(int numberOfInts) {
			int[] ints = new int[numberOfInts];
			for (int i = 0; i < numberOfInts; i++)
				ints[i] = nextInt();
			return ints;
		}
		
		public double[] readNextLineDoubles(int numberOfDoubles) {
			double[] doubles = new double[numberOfDoubles];
			for (int i = 0; i < numberOfDoubles; i++)
				doubles[i] = nextDouble();
			return doubles;
		}
		// --------------------------------------------------------
	}
}