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 (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,a,b=map(int,input().split())
    if(a+b>n+1):
        print(-1)
        return
    if(a*b<n):
        print(-1)
        return

    ans=list(range(b,0,-1))
    now=b
    d=a*b-n
    for _ in range(a-1):
        k=min(d,b-1)
        d-=k
        next=now+(b-k)
        for i in range(next,now,-1):
            ans.append(i)
        now=next

    print(*ans)
resolve()

Solution (Python):
N, A, B = map(int, input().split())
if A*B < N or A+B-1 > N:
    print(-1)
else:
    array = [i for i in reversed(range(1, N+1))]
    if A > 1:
        f = array[:B]
        r = array[B:]
        L = [f]
        span = len(r)//(A-1)
        rem = len(r)%(A-1)
        i = 0
        for _ in range(A-1):
            if rem > 0:
                L.append(r[i:i+span+1])
                rem -= 1
                i += span + 1
            else:
                L.append(r[i:i+span])
                i += span
        array = []
        for l in reversed(L):
            array += l
    print(' '.join([str(a) for a in array]))

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N, A, B = list(map(int, sys.stdin.buffer.readline().split()))
if A * B < N:
    print(-1)
    exit()
if N < A + B - 1:
    print(-1)
    exit()

groups = [[] for _ in range(A)]
nums = deque(list(range(1, N + 1)))
for i in reversed(range(len(groups))):
    groups[i].append(nums.pop())
for i in range(len(groups)):
    nums.append(groups[i].pop())
    for _ in range(B):
        if not nums:
            break
        groups[i].append(nums.popleft())

ans = []
for g in groups:
    ans += g[::-1]
print(*ans)

Solution (Python):
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors







n,a,b = list(map(int, input().split()))
ans=[]
if(n<a+b-1 or n>a*b):
    print(-1)
else:
    if(b>=2):
        x = (n-a)//(b-1)
        y = (n-a)%(b-1)
    else:
        x=1
        y=1
    times=[0 for i in range(b-1)]
    for i in range(a):
        ans.append(n-a+i+1)
    for i in range(b-1):
        if(i<y):
            times[i]=x+1
        else:
            times[i]=x
    now = n-a
    for i in range(b-1):
        now -= times[i]
        for j in range(times[i]):
            ans.append(now+j+1)
print(' '.join(map(str,ans)))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1

def main():
    n, a, b = map(int, input().split())
    if not (n + a - 1) // a <= b <= n - a + 1:
        print(-1)
        exit()
    ans = []
    ans.append(list(range(1, a + 1)))
    
    b -= 1
    st = a + 1
    while b:
        if b == 1:
            ans.append(list(range(st, n + 1)))
            break
        elif n - st + 1 - a >= b - 1:
            ans.append(list(range(st, st + a)))
            st += a
            b -= 1
        else:
            ans.append([st])
            st += 1
            b -= 1
    x = []
    for ak in ans[::-1]:
        x += ak
    print(*x)

main()

Solution (Python):
N, A, B = map(int, input().split())
    
if N < A + B - 1 :
    print(-1)

else :
    if A > B :
        mode = 0
        A -= 1
    else :
        mode = 1
        B -= 1
        
    ret = []
    u = N - A + 1
    l = B
    while len(ret) < N :
        if (mode and A == 0) or (not mode and B == 0) :
            ret = [-1]
            break
            
        if mode :
            for i in range(max(u, l - B + 1), u + A) :
                ret.append(i)
            A -= 1
            u -= A
            mode ^= 1
        else :
            for i in range(min(l, u + A - 1), l - B, -1) :
                ret.append(i)
            B -= 1
            l += B
            mode ^= 1
            
    print(*ret)

Solution (Python):
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
if N < A or N < B:
  print(-1)
  exit(0)
res = [x for x in range(N - A + 1, N + 1)]
k = N - A
if k < B - 1:
  print(-1)
  exit(0)
b = [0] * (B - 1)
for i in range(k):
  b[i % (B - 1)] += 1
if len(b):
  if max(b) > A:
    print(-1)
    exit(0)
for i in b:
  t = [x for x in range(k - i + 1, k + 1)]
  res += t
  k -= i
print(*res)

Solution (Python):
n, a, b = map(int, input().split())

def solve(n, a, b):
    rev = a < b
    if rev:
        b, a = a, b

    if n < a+b-1:
        return [-1]

    if n > a * b:
        return [-1]

    surrogate_ans = []
    for i in range(b):
        nd = i+1
        reminder = n - a*i
        tail = b - nd
        batch_length = min(a, reminder-tail)
        
        batch = range(n+1-a*i-batch_length, n+1-a*i)
        surrogate_ans += batch
        if batch_length != a:
            surrogate_ans += list(reversed(range(1, tail+1)))
        if len(surrogate_ans) == n:
            break

    if rev:
        return reversed(surrogate_ans)
    else:
        return surrogate_ans

print(" ".join(map(str, solve(n, a, b))))

Solution (Python):
def distribute(n, person, min, max, mode="even"):
    
    
    
    if person==0 and n==0:
        return []
    elif not min*person <= n <= max*person:
        return None
    elif mode=="even":
        q, m = divmod(n, person)
        if m==0:
            return [[q, person]]
        else:
            return [[q, person-m], [q+1, m]]
    elif mode=="greedy":
        if max==min:
            return [[max, person]]
        n -= min * person
        q, m = divmod(n, max-min)
        if m==0:
            return [[min, person-q], [max, q]]
        else:
            return [[min, person-1-q], [min+m, 1], [max, q]]
    else:
        raise ValueError("'mode' must be 'even' or 'greedy'.")

import numpy as np
N, A, B = map(int, input().split())
Ans = np.arange(N, 0, -1, dtype=np.int64)
Ans[:A] = np.flipud(Ans[:A])
c = N-A
D = distribute(c, B-1, min=1, max=A, mode="greedy")
if D is None:
    print(-1)
    exit()
idx = A
for p, n in D:
    for n_ in range(n):
        Ans[idx:idx+p] = np.flipud(Ans[idx:idx+p])
        idx += p
print(" ".join(str(int(a)) for a in Ans))

Solution (Python):
def distribute(n, person, min, max, mode="even"):
    
    
    if person==0 and n==0:
        return []
    elif not min*person <= n <= max*person:
        return None
    elif mode=="even":
        q, m = divmod(n, person)
        if m==0:
            return [[q, person]]
        else:
            return [[q, person-m], [q+1, m]]
    elif mode=="greedy":
        n -= min * person
        q, m = divmod(n, max-min)
        if m==0:
            return [[min, person-q], [max, q]]
        else:
            return [[min, person-1-q], [min+m, 1], [max, q]]
    else:
        raise ValueError("'mode' must be 'even' or 'greedy'.")

import numpy as np
N, A, B = map(int, input().split())
Ans = np.arange(N, 0, -1, dtype=np.int64)
Ans[:A] = np.flipud(Ans[:A])
c = N-A
D = distribute(c, B-1, min=1, max=A, mode="even")
if D is None:
    print(-1)
    exit()
idx = A
for p, n in D:
    for _ in range(n):
        Ans[idx:idx+p] = np.flipud(Ans[idx:idx+p])
        idx += p
print(" ".join(str(int(a)) for a in Ans))

Solution (Python):
N, A, B = map(int, input().split())

base = list(range(N, 0, -1))
if A < B:
    tmp = A
    A = B
    B = tmp
    base.reverse()

if (N - 1) // B + 1 <= A <= N - B + 1:
    possible = 1
else:
    possible = 0

if possible:
    split = [A]
    N_left = N - A
    for i in range(B-1, 0, -1):
        split.append((N_left - 1) // i + 1 + split[-1])
        N_left -= (N_left - 1) // i + 1

    split.insert(0, 0)
    ans = []
    for i in range(1, len(split)):
        rev = base[split[i-1]:split[i]]
        rev.reverse()
        ans.extend(rev)
    print(" ".join(map(str, ans)))
else:
    print(-1)

Solution (Python):
import sys
input = sys.stdin.readline

"""
n-増大列、m-減少列まで　-> 長さ nm 以下であることを示す。帰納法。
(n+1)m + 1 項があるとする。(n+2増大 or m+1減少)の存在をいう。
A：左 nm 項 B：右 m+1 項
Aに1項加えると、(n+1,m+1)のどちらかができる。(n+1)-増大ができるとしてよい。
Bの各項 b に対して、bで終わる(n+1)-増大列が存在する。
Bの中に2-増大列があれば(n+2)増大列ができる。そうでなければBが(m+1)-減少列なのでよい

"""

N,A,B = map(int,input().split())

if A+B-1 > N:
    print(-1)
    exit()
if A*B < N:
    print(-1)
    exit()



if B == 1:
    size = [1] * A
else:
    q,r = divmod(N-A,B-1)
    if q < A:
        size = [B] * q + [1+r] + [1] * (A-q-1)
    else:
        size = [B] * A

answer = []
start = 1
for s in size:
    end = start + s
    answer += list(range(end-1, start-1, -1))
    start = end
print(*answer)

Solution (Python):
N, A, B = map(int, input().split())


def f(a, b):
    return [
        p
        for p in [
            N - i * a + j
            for i in range(
                1,
                N // a + 1 if N % a > b - N // a else
                N // a
            )
            for j in range(1, a + 1)
        ] +
        [
            j
            for j in range(
                b - N // a if N % a > b - N // a else
                b - N // a + 1,
                N - (N // a) * a + 1 if N % a > b - N // a else
                N - (N // a - 1) * a + 1
            )
        ] +
        [
            j
            for j in reversed(
                range(
                    1,
                    b - N // a if N % a > b - N // a else
                    b - N // a + 1
                )
            )
        ]
    ]









ans = (
    -1 if A * B < N or A + B > N + 1 else
    ' '.join(
        str(p) if A >= B else
        str(N - p + 1)
        for p in f(max(A, B), min(A, B))
    )
)

print(ans)

Solution (Python):
def main():
    N, A, B = map(int, input().split())
    if N < A:
        print(-1)
        return
    x = -(-N//A)
    if B < x or (N-A+1) < B:
        print(-1)
        return
    lst = list(range(1, N+1))
    seq = [lst[:A]]
    idx = A
    for i in range(B-1):
        rem = B-1-i
        nidx = idx - (-(N-idx)//rem)
        seq.append(lst[idx:nidx])
        idx = nidx
    ans = []
    for s in reversed(seq):
        ans += s
    print(*ans)


if __name__ == "__main__":
    main()

Solution (Python):
n, a, b = [int(item) for item in input().split()]
if n < a + (b-1) or n > a + (b-1) * a:
    print(-1)
    exit()
for i in range(a):
    print(n - a + i + 1, end=" ")
n -= a
if n == 0:
    print("")
    exit()
loop = n // (b-1)
option = n % (b-1)
for j in range(b-1):
    if option > 0:
        for i in range(loop+1):
            print(n - loop - 1 + i + 1, end=" ")
        n -= loop + 1
        option -= 1
    else:
        for i in range(loop):
            print(n - loop + i + 1, end=" ")
        n -= loop
print("")

Solution (Python):




N, A, B = [int(_) for _ in input().split()]
if N < A + B - 1 or A * B < N:
    print(-1)
elif B == 1:
    print(*list(range(1, A + 1)))
else:
    M = N - A - B + 1
    count = [B] * (1 + M // (B - 1))
    count += [1] * (A - len(count))
    count[-1] += (N - A - B + 1) % (B - 1)
    f = 0
    ans = []
    for c in count:
        ans += list(range(f + c, f, -1))
        f += c
    print(*ans)

Solution (Python):
N, A, B = [int(_) for _ in input().split()]
if N < A + B - 1 or A * B < N:
    print(-1)
elif B == 1:
    print(*list(range(1, A + 1)))
else:
    M = N - A - B + 1
    count = [B] * (1 + M // (B - 1))
    count += [1] * (A - len(count))
    count[-1] += (N - A - B + 1) % (B - 1)
    f = 0
    ans = []
    for c in count:
        ans += list(range(f + c, f, -1))
        f += c
    print(*ans)

Solution (Python):



def make_result(n, a, b):
    result = []
    tail = []
    if n < a * b:
        if a <= b:
            k = (a * b - n + b - 2)//(b - 1) - 1
            tail = [n - i for i in range(k - 1, -1, -1)]
            n -= k
            a -= k
            k = n - (a - 1) * b
            tail = [n - i for i in range(k)] + tail
            n -= k
            a -= 1
        else:
            k = (a * b - n + a - 2)//(a - 1) - 1
            result = [n - i for i in range(k)]
            n -= k
            b -= k
            k = n - a * (b - 1)
            result += [n - i for i in range(k - 1, -1, -1)]
            n -= k
            b -= 1

    for i in range(b):
        for j in range(a):
            result.append(n - a * (i + 1) + j + 1)

    return result + tail


def solve(n, a, b):
    if n < a + b - 1:
        return '-1'
    if a * b < n:
        return '-1'

    return ' '.join(map(str, make_result(n, a, b)))


def main():
    n, a, b = input().split()
    n = int(n)
    a = int(a)
    b = int(b)

    print(solve(n, a, b))


if __name__ == '__main__':
    main()

Solution (Python):
n, a, b = map(int, input().split())
if a+b-1 > n or a*b < n:
	print(-1)
elif b == 1:
	print(*list(range(1, n+1)))
else:
	ans = list(range(n-a+1, n+1))
	num = b-1
	mod = n-a - (n-a)//(b-1) * (b-1)
	size1 = (n-a)//(b-1)
	size2 = size1 + 1
	mi = n-a
	for i in range(num):
		if i < num-mod:
			ans += list(range(mi - size1 + 1, mi + 1))
			mi = mi - size1
		else:
			ans += list(range(mi - size2 + 1, mi + 1))
			mi = mi - size2
	print(*ans)

Solution (Python):
n, m, k = map(int,input().split())
if not m+k-1 <= n <= m*k:
    print(-1)
    exit()

streak = [1]*k
streak[0] = m
i = 1
for increment in range(n-m-k+1):
    if streak[i] == m: i+= 1
    streak[i]+= 1
seq = list(range(n, 0, -1))

i = 0
for s in streak:
    subseq = seq[i:i+s]
    seq[i:i+s] = subseq[::-1]
    i+= s
print(*seq)

Solution (Python):
from math import ceil
N,A,B=map(int,input().split())
if N+1<A+B or A*B<N:
  print(-1)
  exit()

t=N//B
s=[]
while N>0:
  if N==A:
    s.append(list(range(1,N+1)))
    break
  if N-B>=A-1:
    s.append(list(range(N,N-B,-1)))
    N-=B
    A-=1
    continue  
  s.append(list(range(N,A-1,-1)))
  s.append(list(range(1,A)))
  break
ans=[]
s.reverse()
for a in s:
  ans.append(' '.join(map(str,a)))
 
print(' '.join(ans))

Solution (Python):
import sys
def inpl(): return [int(i) for i in input().split()]
N, A, B = inpl()
rev = (A < B)
B ,A = sorted([B, A])
if B < -(-N//A) or A+B-1 > N:
    print(-1)
    sys.exit()
st = list(range(1,N+1))
if B == 1:
    ans = st
elif 2*A > N:
    ans = st[A:N-B+1] + st[N-1:N-B:-1] + st[0:A]
else:
    n = N//A
    x = B+(-N//A)+1
    ans = st[n*A:N] + st[(n-1)*A:n*A-x] + st[n*A-1:n*A-x-1:-1]
    for i in range(2,n+1):
        ans += st[(n-i)*A:(n-i+1)*A]
if rev:
    ans = [N+1-i for i in ans]
print(*ans)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def lis(A):
    N = len(A)
    LIS = []

    for i in range(N):
        index = bisect_left(LIS, A[i])
        if index >= len(LIS):
            LIS.append(A[i])
        else:
            LIS[index] = A[i]

    return len(LIS)


def func(A):
    return lis(A), lis([-1 * a for a in A])


def solve(N, A, B):
    ans = []
    now = 1
    num = 0
    while now <= N:
        for i in range(min(N, now + B - 1), now - 1, -1):
            ans.append(i)
        now += B
        num += 1
        rest = N - now + 1
        if 1 + rest - B < A - num:
            break

    for _ in range(A - num - 1):
        ans.append(now)
        now += 1
        num += 1
        if now == N:
            break

    use = False
    for i in range(N, now - 1, -1):
        ans.append(i)
        use = True

    if num + use != A:
        return [-1]

    return ans


def check(N, A, B):
    for p in permutations(range(1, N + 1)):
        if (A, B) == func(list(p)):
            return list(p)
    return [-1]


def main():
    N, A, B = map(int, input().split())
    ans = solve(N, A, B)
    print(*ans)


if __name__ == '__main__':
    main()

Solution (Python):


def solve(n, a, b):
    if a + b - 1 > n:
        return [ -1 ]
    if a * b < n:
        return [ -1 ]

    
    xs = []
    xs += [ (0, - j) for j in range(b) ]
    for i in range(1, a):
        xs += [ (i, 0) ]
        j = 1
        while j < b and len(xs) + (a - i - 1) < n:
            xs += [ (i, - j) ]
            j += 1

    
    f = {}
    for x in sorted(xs):
        k = len(f)
        f[x] = k
    return [ f[x] + 1 for x in xs ]


print(*solve(*map(int, input().split())))

Solution (Python):
N, A, B = map(int, input().split())

ans = list(range(A))
m = 0
rest = N - A
B -= 1
if rest < B:
  print(-1)
  exit()
if rest / A > B:
  print(-1)
  exit()

while rest > B:
  s = min(A, rest - B + 1)
  ans += list(range(m - s, m))
  m -= s
  rest -= s
  B -= 1

ans += list(range(m - B, m))[::-1]
m -= B

print(" ".join([str(x - m + 1) for x in ans]))

Solution (Python):
N,A,B = list(map(int,input().split()))
ans = []
if N >= A + B - 1 and N <= A *B:
    for i in range(A):
        ans.append(str(N - A +1 + i))
        for j in range(B-1):
            if i * (B -1 ) + (B -1 -j) > N - A + B:
              break
            elif i * (B-1) + (B -1 - j ) >= N - A + 1:
                continue
            
            ans.append(str(i * (B-1) + (B-1 - j )))
else:
    ans = ["-1"] 
print(" ".join(ans))

Solution (Python):
N, A, B = map(int, input().split())
def solve():
    if A + B - 1 <= N and N <= A * B:
        if A == 1:
            return [i for i in range(N, 0, -1)]
        s = []
        q = (N - B) // (A - 1)
        r = (N - B) % (A - 1)
        if r == 0:
            q -= 1
            r = A - 1
        for i in range(B - q - 1):
            s.append(N - i)
        for i in range(r + 1):
            s.append(A * q + 1 + i)
        for i in range(q - 1, -1, -1):
            for j in range(A):
                s.append(A * i + j + 1)
        return s
    else:
        return [-1]
print(" ".join(map(str, solve())))

Solution (Python):
n,a,b=map(int,raw_input().split())
if a+b-1>n or a*b<n :
    print -1
else :
    t=0
    for i in range(a-1,-1,-1) :
        
        
        
        sz=min(n-i,b)
        for j in range(sz) :
            print t+sz-j,
        t+=sz
        n-=sz

Solution (Python):
import math

j = list(map(int, input().split()))
n = j[0]
a = j[1]
b = j[2]
if (n < a + b - 1) or (n > a * b):
    print(-1)
    exit(0)

ans = list(range(b, 0, -1))
if (n > b):
    counter = len(ans)
    loopcounter = 1
    
    sikii = b
    yoyuu = n - a -b+1
    while (counter < n):
        if (yoyuu >= sikii):
            ans += list(range(counter + sikii, counter, -1))
            yoyuu -= (sikii - 1)
        elif (yoyuu == 0):
            ans += [counter + 1]
        else:
            ans += list(range(counter + yoyuu + 1, counter, -1))
            yoyuu = 0
        loopcounter += 1
        counter = len(ans)

print(' '.join(map(str, ans)))

Solution (Python):
N, A, B = map(int, input().split())

if A + B - 1 > N or A * B < N:
    print('-1')
else:
    ans = list(range(1, B + 1)[::-1])
    if A > 1:
        x = (N - B) // (A - 1)
        y = (N - B) % (A - 1)
        st = B + 1
        for i in range(y):
            ans += list(range(st, st + x + 1)[::-1])
            st += x + 1
        for i in range(A - 1 - y):
            ans += list(range(st, st + x)[::-1])
            st += x

    print(' '.join(map(str, ans)))

Solution (Python):
N,A,B = map(int,input().split())
if not (A+B-1 <= N <= A*B):
    print(-1)
    exit()
if B == 1:
    print(*list(range(1,A+1)))
    exit()

n = (N-A)//(B-1)
m = (N-A)%(B-1)

stack = [1,A+1]
lds_cnt = 1
while stack[-1] <= N:
    l = n if lds_cnt > m else n+1
    stack.append(stack[-1] + l)
    lds_cnt += 1

ans = []
while len(stack) > 1:
    ans += list(range(stack[-2], stack[-1]))
    stack.pop()
print(*ans)

Solution (Python):
N,A,B = map(int,input().split(" "))

if N < (A + B - 1) or N > (A * B):
	print(-1)
	exit(0)

if B == 1 and A == N:
	seq = [str(n) for n in range(1,N+1)]
	print(' '.join(seq))
	exit(0)

seq = [str(num)for num in range(N-A+1,N+1)]
dif = (A * B - N)
div = A - (dif // (B-1))
mer = (dif % (B-1))

n = N - A
for i in range((B-1) - mer):
	for j in range(n-(div)+1,n+1):
		seq.append(str(j))
	n -= (div)

for i in range(mer):
	for j in range(n-div+2,n+1):
		seq.append(str(j))
	n -= (div - 1)

print(' '.join(seq))

Solution (Python):
N, A, B = map(int, input().split())

ans = list(range(A))
m = 0
rest = N - A
B -= 1
if rest < B:
  print(-1)
  exit()
if rest / A > B:
  print(-1)
  exit()

while rest > B:
  s = min(A, rest - B + 1)
  ans += list(range(m - s, m))
  m -= s
  rest -= s
  B -= 1

ans += list(range(m - B, m))[::-1]
m -= B

print(" ".join([str(x - m + 1) for x in ans]))

Solution (Python):
N,A,B = map(int,input().split())
if A + B > N + 1 or A * B < N:
	print(-1)
	exit()
swap = False
if A < B:
	B,A = A,B
	swap = True

base = [i for i in range(1,A+1)]
rest = N - A
roop = (N + A - 1) // A
if roop == B:
	a = A + 1
	pre = []
	while a <= N:
		pre = [i for i in range(a, min(N+1, a+A))] + pre
		a += A
else:
	pre = [i for i in range(A+B-1, A, -1)]
	r = []
	a = A+B
	while a <= N:
	  r = [i for i in range(a, min(N+1, a+A-1))] + r
	  a += A-1
	pre = pre + r
ans = pre + base
if swap:
	ans = [N-i+1 for i in ans]
print(" ".join(map(str, ans)))

Solution (Python):
def solve(n, a, b):
    if n < a + b - 1:
        return [-1]
    if n > a * b:
        return [-1]
    if b == 1:
        return list(range(1, n + 1))
    if a == 1:
        return list(range(n, 0, -1))

    ans = list(range(b, 0, -1))
    ans.extend(range(n - a + 2, n + 1))

    t = b
    for t in range(2 * b - 1, n - a + 1, b - 1):
        ans.extend(range(t, t - b + 1, -1))
    ans.extend(range(n - a + 1, t, -1))
    return ans


n, a, b = map(int, input().split())
print(*solve(n, a, b))

Solution (Python):
N,A,B = map(int, raw_input().split())

if (N+B-1)/B <= A <= N+1-B:
  L = [A] + [1]*(B-1)
  n = N - A - (B-1)
  for i in range(1, B):
    L[i] += min(n, A-1)
    n -= min(n, A-1)
  T = [[] for _ in range(B)]
  p = 0
  for i in range(1,N+1):
    while len(T[p]) >= L[p]:
      p += 1
    T[p] += [i]
  for t in T[::-1]:
    for x in t:
      print x,
  print
else:
  print -1


"""
from itertools import *


def LIS(L):
  N = len(L)
  res=0
  dp=[1]*N
  for i in range(N):
    for j in range(i):
      if L[j]<L[i]:
        dp[i]=max(dp[i],dp[j]+1)
    res=max(res,dp[i])
  return res

n = 3




n = 4





n = 5






n = 6







n = 7








n = 8









n = 9










n = 10












T = [["."]*(n+1) for _ in range(n+1)]

for x in permutations(range(1,n+1)):
  
  T[LIS(x)][LIS(x[::-1])] = "o"

for t in T[1:]:
  print "".join(t[1:])

"""

Solution (Python):
N, A, B = map(int, input().split())

if N-B+1 < A or A < (N + B-1) // B:
    print(-1)
    exit(0)

res = []
r = []
cnt = 0
for i in range(N):
    r.append(N-i)
    if N-i <= A-cnt or len(r) == B:
        res.append(r)
        r = []
        cnt += 1

if r:
    res.append(r)
ans = []
for r in reversed(res):
    ans.extend(r)
print(*ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,a,b = LI()
    if a+b > n+1:
        return -1
    t = n // b
    if n % b > 0:
        t += 1
    if a < t:
        return -1
    rr = []
    while n > 0:
        if n == a:
            rr.append(list(range(1,n+1)))
            break
        if n-b >= a-1:
            rr.append(list(range(n,n-b,-1)))
            n -= b
            a -= 1
            continue
        rr.append(list(range(n,a-1,-1)))
        rr.append(list(range(1,a)))
        break
    r = []
    rr.reverse()
    for c in rr:
        r.append(' '.join(map(str,c)))

    return ' '.join(r)


print(main())