Buggy python submission (verdict: Time Limit Exceeded):
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 = [deque() for _ in range(A)]
    cnt = N
    blocks[0] = list(range(B, 0, -1))
    flg = True
    while flg:
        flg = False
        for i in range(A-1, 0, -1):
            blocks[i].append(cnt)
            cnt -= 1
            if cnt==B:
                break
        else:
            flg = True
    ans = [0]*N
    cnt = 0
    for b in blocks:
        for a in b:
            ans[cnt] = str(a)
            cnt += 1
    print(' '.join(ans))

Fixed submission:
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))

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
if A+B-1>N or N>A*B:
    print(-1)
else:
    cnt = N
    blocks = [0]*B*A
    for i, b in enumerate(range(B, 0, -1)):
        blocks[i] = b
    flg = True
    loop = 0
    while flg:
        flg = False
        for i in range(A-1, 0, -1):
            blocks[i*B+loop] = cnt
            cnt -= 1
            if cnt==B:
                break
        else:
            flg = True
            loop += 1
    blocks = [i for i in blocks if i!=0]
    print(*blocks)

Fixed submission:
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))

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
if A+B-1>N or N>A*B:
    print(-1)
else:
    cnt = N
    blocks = list(range(B, 0, -1))
    blocks.extend([0]*B*(A-1))
    flg = True
    loop = 0
    while flg:
        flg = False
        for i in range(A-1, 0, -1):
            blocks[i*B-loop] = cnt
            cnt -= 1
            if cnt==B:
                break
        else:
            flg = True
            loop += 1
    blocks = [i for i in blocks if i!=0]
    print(*blocks)

Fixed submission:
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))

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
if A+B-1>N or N>A*B:
    print(-1)
else:
    cnt = N
    blocks = list(range(B, 0, -1))
    blocks.extend([0]*B*(A-1))
    flg = True
    loop = 0
    while flg:
        flg = False
        for i in range(A-1, 0, -1):
            blocks[i*B+loop] = cnt
            cnt -= 1
            if cnt==B:
                break
        else:
            flg = True
            loop += 1
    blocks = [i for i in blocks if i!=0]
    print(*blocks)

Fixed submission:
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))

Buggy python submission (verdict: Time Limit Exceeded):
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 = [deque() for _ in range(A)]
    cnt = N
    blocks[0] = list(range(B, 0, -1))
    flg = True
    while flg:
        flg = False
        for i in range(A-1, 0, -1):
            blocks[i].append(cnt)
            cnt -= 1
            if cnt==B:
                break
        else:
            flg = True
    ans = [0]*N
    cnt = 0
    for b in blocks:
        for a in b:
            ans[cnt] = a
            cnt += 1
    print(*ans)

Fixed submission:
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))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
if A+B-1>N or N>A*B:
    print(-1)
else:
    blocks = [[] for _ in range(A)]
    cnt = N
    blocks[0] = list(range(B, 0, -1))
    flg = True
    while flg:
        flg = False
        for i in range(A-1, 0, -1):
            blocks[i].append(cnt)
            cnt -= 1
            if cnt==B:
                break
        else:
            flg = True
    ans = [0]*N
    cnt = 0
    for b in blocks:
        for a in b:
            ans[cnt] = a
            cnt += 1
    print(*ans)

Fixed submission:
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))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
if A+B-1>N or N>A*B:
    print(-1)
else:
    blocks = [[] for _ in range(A)]
    cnt = N
    blocks[0] = list(range(B, 0, -1))
    flg = True
    while flg:
        flg = False
        for i in range(A-1, 0, -1):
            blocks[i].append(cnt)
            cnt -= 1
            if cnt==B:
                break
        else:
            flg = True
    ans = []
    for b in blocks:
        ans.extend(b)
    print(*ans)

Fixed submission:
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))