Problem:
Score : 700 points

Problem Statement

Determine if there exists a sequence obtained by permuting 1,2,...,N that satisfies the following conditions:

The length of its longest increasing subsequence is A.

The length of its longest decreasing subsequence is B.

If it exists, construct one such sequence.

Notes

A subsequence of a sequence P is a sequence that can be obtained by extracting some of the elements in P without changing the order.

A longest increasing subsequence of a sequence P is a sequence with the maximum length among the subsequences of P that are monotonically increasing.

Similarly, a longest decreasing subsequence of a sequence P is a sequence with the maximum length among the subsequences of P that are monotonically decreasing.

Constraints

1 \leq N,A,B \leq 3\times 10^5

All input values are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

If there are no sequences that satisfy the conditions, print -1.

Otherwise, print N integers. The i-th integer should be the i-th element of the sequence that you constructed.

Sample Input 1

5 3 2

Sample Output 1

2 4 1 5 3

One longest increasing subsequence of this sequence is {2,4,5}, and one longest decreasing subsequence of it is {4,3}.

Sample Input 2

7 7 1

Sample Output 2

1 2 3 4 5 6 7

Sample Input 3

300000 300000 300000

Sample Output 3

-1

Solution in C (GCC 5.4.1) (judge verdict: Accepted)

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define ull unsigned long long

#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))

#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

ll d[300010];
ll n,cnt;
void f(ll a,ll b,ll l,ll r,ll s){
	//[l,r)をincがa,decがb以下になるようs+1からの数で埋める
	if(a==0||b==0){
		puts("-1");
		exit(0);
	}
	if(cnt+a<=n){
		rep(j,0,a)d[r-1-j]=s+a-j;
		cnt+=a;
		if(cnt+b-1<=n){
			rep(i,0,b-1)d[l+i]=s+a+b-1-i;
			cnt+=b-1;
		}else{
			for(ll i=r-a-1;i>=l;i--)d[i]=s+r-i;
			cnt=n;
		}
	}else{
		rep(j,0,n-cnt)d[l+j]=s+1+j;
		cnt=n;
	}
//	printf("%lld %lld %lld %lld %lld\n",a,b,l,r,s);
//	rep(i,0,16)printf("%lld ",d[i]);puts("");
	if(n!=cnt)f(a-1,b-1,l+b-1,r-a,s+a+b-1);
}

int main(){
	ll a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a+b>n+1){
		puts("-1");
		return 0;
	}
	f(a,b,0,n,0);
	rep(i,0,n)printf("%lld ",d[i]);
	puts("");
	return 0;
}