Under construction

Still being built. Things may change

Grand Parade

Time limit2sMemory limit1024 MB

Summary
Given k and n, build an n by n matrix of primes up to 10^7 with exactly k distinct primes and equal divisor counts in every row and column, or print -1.
Level

Medium6 of 10

Topics
Matrix, Number theory, Implementation
Solved
No attempts yet

Statement

Gru wants to hold a grand parade. The main part of the parade is a formation of his mighty army of minions.

The parade takes place on the Central Square, a square with side length nn meters. The square is split into cells of one meter by one meter, so it has n2n^2 cells. In other words, the Central Square is an n×nn \times n matrix.

Gru gave each minion in his army a colored T-shirt with a prime number printed on it. Some T-shirts may show the same number. Now the minions must line up the way Gru wants. Each cell of the square holds exactly one minion.

The formation has two more requirements. First, the parade must include minions whose T-shirts show exactly kk distinct prime numbers. Second, the product of the numbers on the T-shirts in each row and in each column must have the same number of divisors. Gru has only T-shirts with primes not exceeding 10710^7.

Build a formation that meets all requirements, or determine that it is impossible.

Input

The only line contains two integers kk and nn (1≤k≤1091 \le k \le 10^9, 1≤n≤10001 \le n \le 1000), the number of required distinct primes and the size of the square.

Output

Print an n×nn \times n matrix of primes not exceeding 10710^7 that satisfies all requirements. If it is impossible, print -1.

Hints

In the first sample, the row products are 6 and 35, and the column products are 10 and 21. Each of these numbers has 4 divisors. In the second sample, the products of the first row, the third row, the first column, and the third column are 12, while the second row and second column products are 18. Both numbers have 6 divisors each. The third sample is impossible.

Examples3

  1. Example 1

    Input
    4 2
    
    Expected output
    2 3
    7 5
    
  2. Example 2

    Input
    2 3
    
    Expected output
    2 3 2
    3 2 3
    2 3 2
    
  3. Example 3

    Input
    10 3
    
    Expected output
    -1