## COCI '14 Contest 6 #4 Kratki

View as PDF

Points: 10 (partial)
Time limit: 0.6s
Memory limit: 32M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

All of you are probably very familiar with the problem of finding the longest monotone subsequence. You probably think you know all about it. In order to convince us, solve the problem "opposite" to finding the longest monotone subsequence.

For given and , find the sequence that consists of numbers from to such that each of the numbers in it appears exactly once and the length of its longest monotone subsequence (ascending or descending) is exactly .

#### Input

The first line of input contains the integers and , the length of the sequence and the required length of the longest monotone subsequence.

#### Output

If the required sequence doesn't exist, output -1 in the first and only line.

If the required sequence exists, output the required sequence of numbers in the first and only line. Separate the numbers with a single space.

The required sequence (if it exists) is not necessarily unique, so you can output any valid sequence.

#### Sample Input 1

4 3

#### Sample Output 1

1 4 2 3

#### Explanation for Sample Output 1

A sequence of length with longest monotone subsequence of length is . The longest monotone sequence is .

#### Sample Input 2

5 1

#### Sample Output 2

-1

#### Sample Input 3

5 5

#### Sample Output 3

1 2 3 4 5