AtCoder Regular Contest 091 - LISDL

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-----
5 3 2

-----Sample Output-----
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}.

Difficulty: HARD

Starter code:

Solutions:
(N, A, B) = map(int, input().split())
if A + B - 1 > N or A * B < N:
	print(-1)
	return
Q = [[] for i in range(B)]
for i in range(N):
	Q[i // A].append(i + 1)
Q = Q[::-1]
X = N - 1
for i in range(B):
	if len(Q[i]) == 0:
		Q[i].append(Q[-(X // A + 1)][-1])
		del Q[-(X // A + 1)][-1]
		X -= 1
	else:
		break
P = []
for i in range(B):
	for j in range(len(Q[i])):
		P.append(Q[i][j])
print(*P)


import sys

def main(N, A, B):
	if A + B - 1 > N or A * B < N:
		print(-1)
		return
	P = []
	r = A * B - N
	for b in range(B):
		for a in range(A):
			if b >= 1 and a >= 1 and (r > 0):
				if r >= A - 1:
					r -= A - 1
					break
				r -= 1
				continue
			P.append((B - b) * A + a + 1)
	s = sorted([(p, i) for (i, p) in enumerate(P)], key=lambda x: x[0])
	s = sorted([(i, j) for (j, (p, i)) in enumerate(s)], key=lambda x: x[0])
	s = [j + 1 for (i, j) in s]
	print(*s)
input = sys.stdin.readline
(N, A, B) = map(int, input().split())
main(N, A, B)


(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))


import sys
(n, a, b) = map(int, input().split())
if a + b > n + 1 or a * b < n:
	print(-1)
	sys.exit()
ans = []
L = [a] * b
x = a * b - n
for i in range(1, b):
	L[i] -= min(a - 1, x)
	x -= min(a - 1, x)
L.reverse()
ct = 1
for i in range(b):
	l = []
	for j in range(L[i]):
		l.append(str(ct))
		ct += 1
	ans.append(' '.join(l))
ans.reverse()
print(' '.join(ans))


import sys
input_methods = ['clipboard', 'file', 'key']
using_method = 1
input_method = input_methods[using_method]
tin = lambda : map(int, input().split())
lin = lambda : list(tin())
mod = 1000000007

def main():
	(n, a, b) = tin()
	if n < a + b - 1:
		return -1
	if n > a * b:
		return -1
	if a == 1:
		print(*list(range(n, 0, -1)))
		return
	if b == 1:
		print(*list(range(1, n + 1)))
		return
	al = list(range(1, n + 1))
	cc = (n - a) // (b - 1)
	amari = (n - a) % (b - 1)
	ret = al[-a:]
	st = n - a
	for bi in range(b - 1):
		na = cc + (1 if bi < amari else 0)
		st -= na
		for ai in range(na):
			ret.append(al[st + ai])
	print(*ret)
isTest = False

def pa(v):
	if isTest:
		print(v)

def input_clipboard():
	import clipboard
	input_text = clipboard.get()
	input_l = input_text.splitlines()
	for l in input_l:
		yield l

def __starting_point():
	if sys.platform == 'ios':
		if input_method == input_methods[0]:
			ic = input_clipboard()
			input = lambda : ic.__next__()
		elif input_method == input_methods[1]:
			sys.stdin = open('inputFile.txt')
		else:
			pass
		isTest = True
	else:
		pass
	ret = main()
	if ret is not None:
		print(ret)
__starting_point()


(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)


(n, a, b) = map(int, input().split())
turn = 0
if b > a:
	turn = 1
	(a, b) = (b, a)
x = (n + a - 1) // a
if x > b or a + b > n + 1:
	print(-1)
	return
ans = []
m = n % a
now = n
while x < b:
	ans.append(now)
	now -= 1
	if m:
		m -= 1
		x += 1
	else:
		m = a - 1
for i in range((now + a - 1) // a):
	for j in range(a - 1, -1, -1):
		num = now - i * a - j
		if num > 0:
			ans.append(num)
if turn:
	ans = ans[::-1]
print(*ans)


import sys

def input():
	return sys.stdin.readline().strip()

def mapint():
	return map(int, input().split())
sys.setrecursionlimit(10 ** 9)
(N, A, B) = mapint()
from collections import deque
if A + B - 1 > N or N > A * B:
	print(-1)
else:
	blocks = []
	blocks.append(' '.join(map(str, range(B, 0, -1))))
	now = B + 1
	rest = N - A + 2
	while now:
		if now >= rest:
			break
		if now + B > rest:
			blocks.append(' '.join(map(str, range(rest, now - 1, -1))))
			rest += 1
			break
		blocks.append(' '.join(map(str, range(now + B - 1, now - 1, -1))))
		now = now + B
		rest += 1
	blocks.append(' '.join(map(str, range(rest, N + 1))))
	print(' '.join(blocks))


(N, A, B) = map(int, input().split())
if A * B < N:
	print(-1)
elif A + B - 1 > N:
	print(-1)
else:
	P = [0] * N
	b = (N - A) // (B - 1) if B > 1 else 0
	r = (N - A) % (B - 1) + 1 if B > 1 else 1
	i = 1
	pos = 0
	while i <= N:
		if b:
			for j in range(B):
				P[pos + B - j - 1] = i
				i += 1
			pos += B
			b -= 1
		elif r:
			for j in range(r):
				P[pos + r - j - 1] = i
				i += 1
			pos += r
			r = 0
		else:
			P[pos] = i
			i += 1
			pos += 1
	for p in P:
		print(p, end=' ')


(n, a, b) = map(int, input().split())
if a + b - 1 > n or a * b < n:
	print(-1)
	return
L = [[] for _ in range(b)]
L[-1] = list(range(1, a + 1))
for now in range(a + 1, n + 1):
	temp = -2 - (now - (a + 1)) % (b - 1)
	L[temp].append(now)
for l in L:
	print(*l, end=' ')


(n, a, b) = map(int, input().split())
if not a + b - 1 <= n <= a * b:
	print(-1)
	return
n -= a
l = list()
for i in range(b, a * b + 1, b):
	t = min(n, b - 1)
	l += [i - j for j in range(t + 1)]
	n -= t
d = dict()
g = sorted(l)
for (i, x) in enumerate(g, 1):
	d[x] = i
l = list(map(lambda x: d[x], l))
print(*l)


(n, a, b) = map(int, input().split())
if a + b - 1 > n:
	exit(print(-1))
if a * b < n:
	exit(print(-1))
ans = []
c = 0
nn = n
for i in range(a):
	ans.append([])
	t = 0 - -nn // (a - i)
	if i == 0:
		t = b
	nn -= min(t, b)
	for j in range(min(b, t)):
		ans[-1].append((i + 1) * b - j)
		c += 1
		if c == n:
			break
	if c == n:
		break
anss = []
for i in ans:
	anss += i

def position_zip(a, flag):
	j = 1
	d = {}
	for i in sorted(a):
		if i in d:
			continue
		d[i] = j
		j += 1
	if flag == 1:
		return d
	return [d[i] for i in a]
print(*position_zip(anss, 0))


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)
	return
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)))


(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())))


(N, A, B) = map(int, input().split())
if A + B - 1 > N or N > A * B:
	print(-1)
else:
	G = {i: [] for i in range(1, A + 1)}
	i = A
	cnt = 0
	cur = N
	while cur > A:
		G[i].append(cur)
		cnt += 1
		cur -= 1
		if cnt == B - 1:
			cnt = 0
			i -= 1
	C = []
	for i in range(1, A + 1):
		C += G[i]
		C.append(i)
	print(*C)


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)
	return
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)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
(N, A, B) = MAP()
if A * B < N:
	print(-1)
	exit()
if A + B > N + 1:
	print(-1)
	exit()
if A == 1 and B != N or (B == 1 and A != N):
	print(-1)
	exit()
remain = N - A
if remain < B - 1:
	print(-1)
	exit()
(d, m) = divmod(remain, B - 1) if B > 1 else (0, 0)
if d > A:
	print(-1)
	exit()
li = [[] for i in range(B)]
li[0] = list(range(1, A + 1))
j = A + 1
for i in range(1, B):
	tmp = []
	for _ in range(d):
		tmp.append(j)
		j += 1
	if m > 0:
		tmp.append(j)
		j += 1
		m -= 1
	li[i] = tmp
li = li[::-1]
ans = []
for grp in li:
	ans += grp
print(*ans)


(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)


max2 = lambda x, y: x if x > y else y

def solve(N, A, B):
	if A + B > N + 1:
		return None
	if A * B < N:
		return None
	res = [-1] * N
	rem = A
	i = 0
	while i + B + rem - 1 < N:
		rem -= 1
		o = i + B
		for k in range(B):
			res[i + k] = o - k - 1
		i += B
	p = N - i - rem + 1
	for k in range(p):
		res[i + k] = i + p - k - 1
	i += p
	rem -= 1
	for k in range(i, N):
		res[k] = k
	return res
from itertools import permutations

def naive(N, A, B):
	for p in permutations(range(N)):
		dp = [1] * N
		for i in range(N):
			for j in range(i):
				if p[j] < p[i]:
					dp[i] = max2(dp[i], dp[j] + 1)
		a = max(dp)
		dp = [1] * N
		for i in range(N):
			for j in range(i):
				if p[j] > p[i]:
					dp[i] = max2(dp[i], dp[j] + 1)
		b = max(dp)
		if a == A and b == B:
			return p
	return None

def __starting_point():
	(N, A, B) = map(int, input().split())
	res = solve(N, A, B)
	if res is None:
		print(-1)
	else:
		print(*(v + 1 for v in res))
__starting_point()


(N, A, B) = list(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)


(N, A, B) = map(int, input().split())
if A * B < N or A + B - 1 > N:
	print(-1)
	exit()
rev = B > A
(A, B) = (max(A, B), min(A, B))
B -= 1
M = N
ans1 = []
ans2 = []
while M > 0:
	if len(ans1) == len(ans2):
		temp = [i for i in range(M + 1 - A, M + 1)]
		ans1.append(temp)
		M = M - A
		A -= 1
	else:
		temp = [i for i in range(M + 1 - B, M + 1)]
		temp = temp[::-1]
		ans2.append(temp)
		M = M - B
		B -= 1
ans2 = ans2[::-1]
res = []
for L in ans1:
	res += L
for L in ans2:
	res += L
res = [val for val in res if val > 0]
if rev:
	res = res[::-1]
print(*res)


(n, a, b) = map(int, input().split())
if (n > a * b) | (a + b > n + 1):
	print(-1)
	exit()
if (a == 1) | (b == 1):
	if b == n:
		ans = list(range(n, 0, -1))
		print(' '.join(map(str, ans)))
	elif a == n:
		ans = list(range(1, n + 1))
		print(' '.join(map(str, ans)))
	else:
		print(-1)
	exit()
ans = []
top = n
while top > 0:
	if top - a >= b:
		for i in range(top - a + 1, top + 1):
			ans.append(i)
		top -= a
		b -= 1
		continue
	a = top - b + 1
	for i in range(top - a + 1, top + 1):
		ans.append(i)
	for i in range(b - 1, 0, -1):
		ans.append(i)
	break
print(' '.join(map(str, ans)))


(n, a, b) = map(int, input().split())
if a + b > n + 1 or a * b < n:
	print(-1)
	return
l = []
used = 0
for i in range(a):
	tmp = []
	for j in range(b):
		tmp.append(used + 1)
		used += 1
		if n - used == a - i - 1:
			break
	l.extend(tmp[::-1])
print(*l)


def main():
	(N, A, B) = map(int, input().split())
	if not (N - 1) // A + 1 <= B <= N - A + 1:
		print(-1)
		return
	if B == 1:
		print(*range(1, N + 1))
		return
	(q, r) = divmod(N - A, B - 1)
	ctr = [A]
	ctr += [q] * (B - 1 - r)
	ctr += [q + 1] * r
	ans = []
	ma = N
	for x in ctr:
		ans += list(range(ma - x + 1, ma + 1))
		ma -= x
	print(*ans)
main()


(N, A, B) = map(int, input().split())
if A + B > N + 1 or A * B < N:
	print(-1)
	return
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)))


import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10 ** 9))
write = lambda x: sys.stdout.write(x + '\n')
(n, a, b) = map(int, input().split())

def sub(n, a, b):
	ps = list(range(a))
	for i in range(1, b):
		ps.append(-a * i)
	count = a + b - 1
	if count == n:
		return ps
	for i in range(1, b):
		for j in range(1, a):
			ps.append(-a * i + j)
			count += 1
			if count == n:
				break
		if count == n:
			break
	return ps
if a + b > n + 1:
	ans = -1
elif a * b < n:
	ans = -1
else:
	ps = sub(n, a, b)
	pps = [(i + 1, p) for (i, p) in enumerate(ps)]
	pps.sort(key=lambda x: x[1])
	ans = [item[0] for item in pps]
if ans == -1:
	print(ans)
else:
	write(' '.join(map(str, ans)))


(n, a, b) = map(int, input().split())
if a + b > n + 1 or a * b < n:
	print(-1)
	return
ans = []
for i in range(1, a + 1):
	ans.append(i * b)
if b == 1:
	x = list(range(1, n + 1))
	print(*x)
	return
x = (n - a) // (b - 1)
y = (n - a) % (b - 1)
for i in range(1, b):
	for j in range(1, x + 1):
		ans.append(j * b - i)
	if i <= y:
		ans.append((x + 1) * b - i)
ans_true = []
for (i, x) in enumerate(ans):
	ans_true.append((i + 1, x))
ans_true.sort(key=lambda x: x[1])
x = list(zip(*ans_true))[0]
print(*x)


(r, p) = (range, print)
(n, a, b) = map(int, input().split())
if a + b > n + 1 or a * b < n:
	print(-1)
	return
l = [[] for i in r(b - 1)] + [list(r(1, a + 1))]
for i in r(a + 1, n + 1):
	l[-2 - (i - a - 1) % (b - 1)].append(i)
for i in l:
	p(*i, end=' ')


(n, a, b) = map(int, input().split())
ans = []
L = [a] * b
x = a * b - n
ct = 1
if a + b > n + 1 or x < 0:
	print(-1)
	exit()
for i in range(b - 1, 0, -1):
	y = min(a - 1, x)
	L[i] -= y
	x -= y
for i in L:
	l = []
	for j in range(i):
		l += [str(ct)]
		ct += 1
	ans += [' '.join(l)]
print(*reversed(ans))


def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getArray(intn):
	return [int(input()) for i in range(intn)]

def input():
	return sys.stdin.readline().rstrip()

def rand_N(ran1, ran2):
	return random.randint(ran1, ran2)

def rand_List(ran1, ran2, rantime):
	return [random.randint(ran1, ran2) for i in range(rantime)]

def rand_ints_nodup(ran1, ran2, rantime):
	ns = []
	while len(ns) < rantime:
		n = random.randint(ran1, ran2)
		if not n in ns:
			ns.append(n)
	return sorted(ns)

def rand_query(ran1, ran2, rantime):
	r_query = []
	while len(r_query) < rantime:
		n_q = rand_ints_nodup(ran1, ran2, 2)
		if not n_q in r_query:
			r_query.append(n_q)
	return sorted(r_query)
from collections import defaultdict, deque, Counter
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
(N, A, B) = getNM()
if A * B < N or N + 1 < A + B:
	print(-1)
	return
if A == 1:
	if B == N:
		print(*[i for i in range(N, 0, -1)])
	else:
		print(-1)
	return
if B == 1:
	if A == N:
		print(*[i for i in range(1, N + 1)])
	else:
		print(-1)
	return
res1 = [i + 1 for i in range(N - A, N)]
res2 = []
L = [i + 1 for i in range(N - A - 1, -1, -1)]
ind = (N - A) // (B - 1)
for i in range(B - 1):
	opt = []
	for j in range(ind + (i < (N - A) % (B - 1))):
		u = L.pop()
		opt.append(u)
	res2.append(opt)
res2 = list(reversed(res2))
ans = res1
for i in range(B - 1):
	ans += res2[i]

def lis(A):
	L = [A[0]]
	for a in A[1:]:
		if a > L[-1]:
			L.append(a)
		else:
			L[bisect_left(L, a)] = a
	return len(L)
print(*ans)


def main(n, a, b):
	if not a * b >= n >= a + b - 1:
		return [-1]
	ans = []
	flg = False
	for x in range(b):
		if not flg:
			for y in range(a):
				ans.append(b - x + b * y)
				if len(ans) + (b - x) == n:
					if y != a - 1:
						ans.append(b - x + b * (a - 1))
					else:
						ans.append(b - (x + 1))
					flg = True
					break
		elif flg:
			ans.append(b - x + b * (a - 1))
	c = ans.copy()
	c.sort()
	from bisect import bisect_right
	ans = [bisect_right(c, x) for x in ans]
	return ans
(n, a, b) = map(int, input().split())
ary = main(n, a, b)
print(*ary, sep=' ')


(n, m, k) = map(int, input().split())
if not m + k - 1 <= n <= m * k:
	print(-1)
	return
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)


import math
(n, a, b) = map(int, input().split())
f = 1
ans = [0] * n
if max(a, b) > n:
	f = 0
elif not math.ceil((n - a) / a) + 1 <= b <= n - a + 1:
	f = 0
if f:
	ans[-a] = 1
	if not b == 1:
		(c, d) = ((n - a) // (b - 1), b - 1 - (n - a) % (b - 1))
		now = n + 1
		i = 0
		for j in range(b - 1):
			now -= c
			if j >= d:
				now -= 1
			ans[i] = now
			i += c
			if j >= d:
				i += 1
	for i in range(1, n):
		if ans[i] == 0:
			ans[i] = ans[i - 1] + 1
print(' '.join(map(str, ans)) if f else -1)


import sys
input = sys.stdin.readline
(N, A, B) = map(int, input().split())
if A + B - 1 > N:
	print(-1)
	exit()
a = []
b = []
while N > 0:
	if A == 0 or B == 0:
		print(-1)
		exit()
	if B >= N:
		b = list(range(N, 0, -1)) + b
		N = 0
	else:
		b = list(range(N, N - B, -1)) + b
		N -= B
		if A - 1 >= N:
			a += list(range(1, N + 1))
			N = 0
		else:
			a += list(range(N - A + 2, N + 1))
			N -= A - 1
	A -= 1
	B -= 1
ans = a + b
print(*ans)


(n, a, b) = list(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 = list(range(n + 1 - a * i - batch_length, n + 1 - a * i))
		surrogate_ans += batch
		if batch_length != a:
			surrogate_ans += list(reversed(list(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))))


import sys
input = sys.stdin.readline

def I():
	return int(input())

def MI():
	return list(map(int, input().split()))

def LI():
	return list(map(int, input().split()))

def main():
	mod = 10 ** 9 + 7
	(N, A, B) = MI()
	if A + B > N + 1:
		print(-1)
		return
	t = (N + B - 1) // B
	if A < t:
		print(-1)
		return
	if A == 1:
		if B == N:
			ans = list(range(N, 0, -1))
			print(' '.join(map(str, ans)))
			return
		else:
			print(-1)
			return
	if B == 1:
		if A == N:
			ans = list(range(1, N + 1))
			print(' '.join(map(str, ans)))
			return
		else:
			print(-1)
			return
	ans = []
	temp = list(range(N - A + 1, N + 1))
	ans += temp
	unit = (N - A) // (B - 1)
	rem = (N - A) % (B - 1)
	right = N - A
	for i in range(B - 1):
		left = right - unit
		if rem:
			left -= 1
			rem -= 1
		temp = list(range(left + 1, right + 1, 1))
		ans += temp
		right = left
	print(' '.join(map(str, ans)))
main()


import sys
input = sys.stdin.readline
(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)


(n, a, b) = map(int, input().split())
if a * b < n:
	print(-1)
elif a + b - 1 > n:
	print(-1)
else:
	if a * b == n:
		l = [b] * a
	else:
		l = [b] * ((n - a) // (b - 1)) + [(n - a) % (b - 1) + 1] + [1] * (a - 1 - (n - a) // (b - 1))
	j = 0
	c = 0
	ans = [0] * n
	for i in l:
		c += i
		for k in range(c, c - i, -1):
			ans[j] = k
			j += 1
	print(' '.join(map(str, ans)))


import sys
input = sys.stdin.readline
(n, a, b) = map(int, input().split())
nn = n
bb = b
if (n + b - 1) // b <= a <= n + 1 - b:
	ANS = []
	L = [a]
	b -= 1
	n -= a
	for i in range(b):
		L.append(1)
		n -= 1
	ind = 1
	while n > 0:
		p = min(n, a - 1)
		L[ind] += p
		n -= p
		ind += 1
	i = nn
	for j in range(bb):
		i -= L[j]
		for k in range(L[j]):
			ANS.append(i + k + 1)
	print(*ANS)
else:
	print(-1)


(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))


(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]))


def examC():
	N = LI()
	N.sort()
	if N[0] == 1:
		if N[1] == 1:
			ans = 1
		else:
			ans = max(0, N[1] - 2)
	else:
		ans = (N[1] - 2) * (N[0] - 2)
	print(ans)
	return

def examD():
	(N, K) = LI()
	ans = 0
	b = K + 1
	while b <= N:
		cur = N // b * (b - K) + max(0, N % b - K + 1)
		if cur == N + 1:
			cur = N
		ans += cur
		b += 1
	print(ans)
	return

def examE():
	(N, A, B) = LI()
	if N < A + B - 1 or N > A * B:
		print(-1)
		return
	ans = []
	cur = N
	num = N
	rest = B - 1
	for i in range(B):
		cur -= A
		if cur <= rest:
			cur += A
			break
		for j in range(A):
			if num == rest:
				break
			ans.append(cur + 1)
			cur += 1
			num -= 1
		cur -= A
		rest -= 1
	for i in range(rest, cur):
		ans.append(i + 1)
	cur = rest
	for j in range(rest):
		ans.append(cur)
		cur -= 1
	print(' '.join(map(str, ans)))
	return

def examF():
	ans = 0
	print(ans)
	return
import sys, copy, bisect, itertools, heapq, math
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LSI():
	return list(map(str, sys.stdin.readline().split()))

def LS():
	return sys.stdin.readline().split()

def SI():
	return sys.stdin.readline().strip()
nonlocal mod, mod2, inf, alphabet
mod = 10 ** 9 + 7
mod2 = 998244353
inf = 10 ** 18
alphabet = [chr(ord('a') + i) for i in range(26)]

def __starting_point():
	examE()
__starting_point()


(N, A, B) = map(int, input().split())
if A + B > N + 1 or A * B < N:
	print(-1)
	return
distributes = [1] * A
remain = N - A
for i in range(A):
	d = min(remain, B - 1)
	distributes[i] += d
	remain -= d
marker = 1
ans = []
for d in distributes:
	ans.extend(list(range(marker, marker + d))[::-1])
	marker += d
print(*ans, sep=' ')


(N, A, B) = map(int, input().split())
a = list(range(N - A + 1, N + 1))
for i in range(B - 1, 0, -1):
	a.append(i)
(m, M) = (B, N - A)
for j in range(A - 1):
	for i in range(min(M, m + B - 2), m - 1, -1):
		a.append(i)
	m = min(M, m + B - 2) + 1
	if len(a) == N:
		break
print(*(a if len(a) == N else [-1]))


(N, A, B) = map(int, input().split())
if A + B > N + 1 or A * B < N:
	print(-1)
	exit()
ls = [1] * B
rem = N - B
i = 0
while rem > 0:
	r = min(A - 1, rem)
	ls[i] += r
	rem -= r
	i += 1
bs = [[] for _ in range(B)]
n = 1
for (j, l) in enumerate(ls):
	for i in range(l):
		bs[j].append(n)
		n += 1
ans = []
for b in reversed(bs):
	ans += b
print(*ans)


import math
import queue
from collections import deque, defaultdict
import heapq as hpq
from sys import stdin, setrecursionlimit
ipt = stdin.readline
setrecursionlimit(10 ** 7)

def main():
	(n, a, b) = map(int, ipt().split())
	if a * b < n or a + b - 1 > n:
		print(-1)
		exit()
	ans = [str(b - i) for i in range(b)]
	si = n - a + 2
	ue = n + 1
	i = 0
	while True:
		if si <= b or a == 1:
			break
		ans[i] += ' ' + ' '.join(map(str, range(si, ue)))
		ue = si
		si -= a - 1
		i += 1
	if i < b and b + 1 < ue:
		ans[i] += ' ' + ' '.join(map(str, range(b + 1, ue)))
	print(' '.join(ans))
	return
main()


import sys
from bisect import bisect

def Longest_Increasing_Subsequence(N, lst):
	MM = max(lst) + 1
	data = [MM] * (N + 1)
	data[0] = 0
	for i in range(N):
		b = bisect(data, lst[i])
		data[b] = lst[i]
	ANS = 1
	for i in range(1, N + 1):
		if data[i] != MM:
			ANS = i
	return ANS

def Longest_Decreasing_Subsequence(N, lst):
	MM = max(lst) + 1
	data = [MM] * (N + 1)
	lst = lst[::-1]
	data[0] = 0
	for i in range(N):
		b = bisect(data, lst[i])
		data[b] = lst[i]
	ANS = 1
	for i in range(1, N + 1):
		if data[i] != MM:
			ANS = i
	return ANS
(N, A, B) = map(int, input().split())
(AAA, BBB) = (A, B)
if A > N or B > N:
	print(-1)
	return
if B > N - A + 1:
	print(-1)
	return
ans = []
L = 1
R = N
flag = [0] * (N + 1)
flag[0] = 1
if A < B:
	B -= 1
	while A > 0 and B > 0 and (len(ans) < N):
		for i in range(max(1, R - A + 1), R + 1):
			if flag[i] == 0:
				flag[i] = 1
				ans.append(i)
		R -= A
		A -= 1
		for i in range(min(N, L + B - 1), L - 1, -1):
			if flag[i] == 0:
				flag[i] = 1
				ans.append(i)
		L += B
		B -= 1
	for i in range(min(N, L + B - 1), L - 1, -1):
		if flag[i] == 0:
			flag[i] = 1
			ans.append(i)
elif A == B:
	B -= 1
	while A > 0 and B > 0 and (len(ans) < N):
		for i in range(max(1, R - A + 1), R + 1):
			if flag[i] == 0:
				flag[i] = 1
				ans.append(i)
		R -= A
		A -= 1
		for i in range(min(N, L + B - 1), L - 1, -1):
			if flag[i] == 0:
				flag[i] = 1
				ans.append(i)
		L += B
		B -= 1
	for i in range(max(1, R - A + 1), R + 1):
		if flag[i] == 0:
			flag[i] = 1
			ans.append(i)
else:
	A -= 1
	while A > 0 and B > 0 and (len(ans) < N):
		for i in range(min(N, L + B - 1), L - 1, -1):
			if flag[i] == 0:
				flag[i] = 1
				ans.append(i)
		L += B
		B -= 1
		for i in range(max(1, R - A + 1), R + 1):
			if flag[i] == 0:
				flag[i] = 1
				ans.append(i)
		R -= A
		A -= 1
	for i in range(max(1, R - A + 1), R + 1):
		if flag[i] == 0:
			flag[i] = 1
			ans.append(i)
if len(ans) >= N:
	ans = ans[:N]
	if Longest_Increasing_Subsequence(N, ans) == AAA and Longest_Decreasing_Subsequence(N, ans) == BBB:
		print(*ans)
	else:
		print(-1)
else:
	print(-1)


(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)


printn = lambda x: print(x, end='')
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
ins = lambda : input().strip()
DBG = True
BIG = 10 ** 18
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)
(n, a, b) = inm()
flip = False
if a < b:
	(a, b) = (b, a)
	flip = True
if a * a < n or n < a or a + b - 1 > n or (a * b < n):
	print(-1)
	return
d = [0] * (a + 1)
m = n
for i in range(1, a + 1):
	d[i] = min(b, m - (a - i))
	m -= d[i]
t = []
x = 1
for z in d[1:]:
	y = list(range(x, x + z))
	x += z
	y.reverse()
	t.extend(y)
if flip:
	t.reverse()
print(' '.join([str(x) for x in t]))


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))


(n, a, b) = [int(item) for item in input().split()]
if n < a + (b - 1) or n > a + (b - 1) * a:
	print(-1)
	return
for i in range(a):
	print(n - a + i + 1, end=' ')
n -= a
if n == 0:
	print('')
	return
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('')


import sys
sr = lambda : sys.stdin.readline().rstrip()
ir = lambda : int(sr())
lr = lambda : list(map(int, sr().split()))
(N, A, B) = lr()
if A + B - 1 > N:
	print(-1)
	exit()
if A * B < N:
	print(-1)
	exit()
if B == 1:
	(q, r) = (A, 0)
else:
	(q, r) = divmod(N - A, B - 1)
if q == A:
	size = [B] * q
else:
	size = [B] * q + [r + 1] + [1] * (A - q - 1)
end = 1
answer = []
for s in size:
	start = end + s - 1
	answer.extend(list(range(start, end - 1, -1)))
	end = start + 1
print(*answer)


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())


(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)


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()


(N, A, B) = map(int, input().split())
if A + B - 1 > N or A * B < N:
	print(-1)
	return
ans = []
x = N - A
cur = 1
while cur <= N:
	y = min(x + 1, B)
	ans += list(reversed(range(cur, cur + y)))
	cur += y
	x -= y - 1
print(*ans)


(n, a, b) = map(int, input().split())
ans = []
L = [a] * b
x = a * b - n
ct = 1
for i in range(b - 1, 0, -1):
	y = min(a - 1, x)
	L[i] -= y
	x -= y
for i in range(b):
	l = []
	for j in range(L[i]):
		l.append(str(ct))
		ct += 1
	ans.append(' '.join(l))
ans.reverse()
print(-1 if a + b > n + 1 or a * b < n else ' '.join(ans))


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()


(n, a, b) = map(int, input().split())
min_b = -(-n // a)
if not (min_b <= b and a + b <= n + 1):
	print(-1)
	exit()
ans = []
i = 0
while True:
	tmp = []
	break_flag = False
	for j in range(a):
		if i * a + j >= n:
			break_flag = True
			break
		tmp.append(i * a + j + 1)
	if not tmp:
		break
	ans.append(tmp)
	i += 1
	if break_flag:
		break
ans.sort(reverse=True)
nokori_b = b - len(ans)
for i in range(len(ans) - 1):
	cnt_elems = len(ans[i])
	if nokori_b >= len(ans[i]) - 1:
		ans[i].sort(reverse=True)
		nokori_b -= len(ans[i]) - 1
	else:
		ans[i] = sorted(ans[i][:nokori_b + 1], reverse=True) + ans[i][nokori_b + 1:]
		break
res = []
for li in ans:
	for num in li:
		res.append(num)
print(*res)


import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right
sys.setrecursionlimit(10 ** 7)

def input():
	return sys.stdin.readline()[:-1]
mod = 10 ** 9 + 7

def I():
	return int(input())

def LI():
	return list(map(int, input().split()))

def LIR(row, col):
	if row <= 0:
		return [[] for _ in range(col)]
	elif col == 1:
		return [I() for _ in range(row)]
	else:
		read_all = [LI() for _ in range(row)]
		return map(list, zip(*read_all))
(N, A, B) = LI()
if math.ceil(N / A) <= B <= N - A + 1:
	numl = [1] * A
	numl[0] = B
	left = N - A - B + 1
	for i in range(1, A):
		val = min(left, B - 1)
		numl[i] += val
		left -= val
	ans = []
	now = 1
	for i in range(A):
		ans.extend(list(reversed(range(now, now + numl[i]))))
		now += numl[i]
	print(*ans)
else:
	print(-1)


(N, A, B) = map(int, input().split())
if A * B < N or A + B > N + 1:
	print(-1)
	return
X = [[i * B] for i in range(A)]
s = N - A
i = 0
while s:
	if len(X[i]) >= B:
		i += 1
	X[i].append(X[i][-1] - 1)
	s -= 1
Y = []
for x in X:
	for xx in x:
		Y.append(xx)
D = {a: i for (i, a) in enumerate(sorted(Y))}
Y = [D[y] + 1 for y in Y]
print(*Y)


(N, A, B) = map(int, input().split())
if not A + B - 1 <= N <= A * B:
	print(-1)
	return
if B == 1:
	print(*list(range(1, A + 1)))
	return
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)


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


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))
main()


import sys
import collections
import itertools
sys.setrecursionlimit(10 ** 8)
inm = lambda : map(int, sys.stdin.readline().split())
(N, A, B) = inm()

def solve():
	if A + B > N + 1:
		return None
	(a, b) = (N, 1)
	b += B - 1
	a -= B - 1
	s = []
	s.append(range(B, 0, -1))
	la = 1
	p = B + 1
	ra = N - p + 1
	while la + ra > A:
		p2 = p + min(B, la + ra - A + 1)
		s.append(range(p2 - 1, p - 1, -1))
		p = p2
		la += 1
		ra = N + 1 - p
		if la == A and ra > 0:
			return None
	assert la + ra == A
	s.append(range(p, N + 1))
	return list(itertools.chain.from_iterable(s))
ans = solve()
if ans is None:
	print(-1)
else:
	print(*ans)


(N, A, B) = map(int, input().split())
if A + B > N + 1:
	print(-1)
	return
(res, tmp) = ([], [])
(k, l, cnt, sign, m1, m2) = (N + 1, 0, 0, 1, 0, 0)
while k != l + 1:
	if m1 >= A or m2 >= B:
		print(-1)
		return
	if sign == 1:
		if cnt < A - m1:
			k -= 1
			tmp.append(k)
			cnt += 1
		else:
			res.extend(reversed(tmp))
			tmp = []
			cnt = 0
			sign = 0
			m2 += 1
	elif cnt < B - m2:
		l += 1
		tmp.append(l)
		cnt += 1
	else:
		res.extend(reversed(tmp))
		tmp = []
		cnt = 0
		sign = 1
		m1 += 1
res.extend(reversed(tmp))
print(*res)


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)
main()


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) = list(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)
	return
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)))


import sys
input = sys.stdin.readline
from collections import defaultdict
mod = 10 ** 9 + 7
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

def main():
	(N, A, B) = getlist()
	if 1 + N < A + B or N > A * B:
		print(-1)
		return
	ans = [i for i in range(N, N - B, -1)]
	N2 = N - B
	A2 = A - 1
	if A2 == 0:
		print(*ans)
		return
	p = N2 // A2
	q = N2 % A2
	B = [p] * A2
	B.append(0)
	for i in range(q):
		B[i] += 1
	Bsum = [0] * A2
	for i in range(A2):
		Bsum[i] = Bsum[i - 1] + B[i]
	pre = []
	for i in range(A2):
		for j in range(B[i]):
			pre.append(Bsum[i] - j)
	answer = pre + ans
	print(*answer)

def __starting_point():
	main()
__starting_point()


def main():
	(n, a, b) = map(int, input().split())
	if b < (n - 1) // a + 1 or n - a + 1 < b:
		print(-1)
		return 0
	for i in range((n - 1) // a + 1, n - a + 2):
		cnt_a = i - (n - 1) // a
		cnt_b = b - cnt_a - 1
		length = n - cnt_a * a - cnt_b
		if length <= a:
			break
	j = n + 1
	ans = []
	for i in range(cnt_a):
		j -= a
		ans += list(range(j, j + a))
	if cnt_b >= 0:
		j -= length
		ans += list(range(j, j + length)) + list(range(j - 1, 0, -1))
	print(*ans)
main()


(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)))


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())))


import sys
(N, A, B) = map(int, input().split())
if A + B - 1 > N or A * B < N:
	print(-1)
	sys.exit()
ans = []
for i in range(N - A + 1, N + 1, 1):
	ans.append(i)
now = []
for i in range(1, N - A + 1, 1):
	now.append(i)
	if len(now) == B - 1:
		now.reverse()
		for j in now:
			ans.append(j)
		now = []
now.reverse()
for j in now:
	ans.append(j)
print(' '.join(map(str, ans)))


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)))


(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)


(N, A, B) = map(int, input().split())
ans = []
if A + B - 1 <= N <= A * B:
	S = N - A
	cur = N
	ans = []
	for i in range(A + 1):
		num = min(B - 1, S) + 1
		S -= num - 1
		for j in range(num):
			ans.append(cur - num + 1 + j)
		cur -= num
	ans = ans[::-1][1:]
	print(*ans)
else:
	print(-1)
from bisect import bisect

def LIS(L):
	(INF, N) = (10 ** 12, len(L))
	seq = [INF] * N
	for i in L:
		seq[bisect(seq, i)] = i
	return N - seq.count(INF)


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)
main()


(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]))


from math import ceil
(N, A, B) = map(int, input().split())
if N + 1 < A + B or A * B < N:
	print(-1)
	return
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))


(N, A, B) = map(int, input().split())
ans = []
if A + B - 1 <= N <= A * B:
	S = N - A
	cur = N
	ans = []
	for i in range(A + 1):
		num = min(B - 1, S) + 1
		S -= num - 1
		for j in range(num):
			ans.append(cur - num + 1 + j)
		cur -= num
	ans = ans[::-1][1:]
	print(*ans)
else:
	print(-1)


(n, a, b) = [int(x) for x in input().split()]
if a * b < n or n < a + b - 1:
	print(-1)
else:
	ans = []
	remaining = n - a
	to_insert = 1
	for i in range(a):
		ans.append(to_insert)
		to_insert += 1
		inserted = 1
		for j in range(min(b - 1, remaining)):
			ans.append(to_insert)
			to_insert += 1
			inserted += 1
			remaining -= 1
		ans[-inserted:] = reversed(ans[-inserted:])
	print(*ans)