cho.sh
Notes
Loading...

Constructing a Permutation

Time limit

2s

Memory limit

128 MB

Problem

Consider a permutation of length N in which each integer from 1 to N appears exactly once. If some elements are removed while preserving the relative order of the remaining elements, the result is a subsequence.

A subsequence is increasing if its elements strictly increase from left to right, and decreasing if they strictly decrease. Let M be the length of the longest increasing subsequence and K be the length of the longest decreasing subsequence.

Given three integers N, M, and K, construct a permutation of length N whose longest increasing subsequence has length exactly M and whose longest decreasing subsequence has length exactly K.

Input

The first line contains three integers N, M, and K: the permutation length, the required longest increasing subsequence length, and the required longest decreasing subsequence length.

1 <= N <= 100000

1 <= M, K <= N

Output

If no valid permutation exists, print only -1 on the first line.

Otherwise, print the lexicographically smallest valid permutation on the first line and the lexicographically largest valid permutation on the second line.