In a cricket game, an over is a set of six valid deliveries of balls performed by one player ― the bowler for this over.
Consider a cricket game with a series of $N$ overs (numbered $1$ through $N$) played by $K$ players (numbered $1$ through $K$). Each player may be the bowler for at most $L$ overs in total, but the same player may not be the bowler for any two consecutive overs. Assign exactly one bowler to each over in such a way that these rules are satisfied or determine that no such assignment exists.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains three space-separated integers $N$, $K$ and $L$. 

-----Output-----
For each test case:
- If there is no valid assignment of bowlers to overs, print a single line containing the integer $-1$.
- Otherwise, print a single line containing $N$ space-separated integers. For each valid $i$, the $i$-th of these integers should be the number of the player assigned as the bowler for the $i$-th over.

-----Constraints-----
- $1 \le T \le 30$
- $1 \le N, K, L \le 10,000$

-----Example Input-----
2
4 3 2
5 4 1

-----Example Output-----
1 2 3 2
-1

-----Explanation-----
Example case 1: The following is a valid assignment:
- Bowler 1 bowls the $1$-st over.
- Bowler 2 bowls the $2$-nd and $4$-th overs.
- Bowler 3 bowls the $3$-rd over.
It is valid since no bowler bowls more than $2$ overs and each two consecutive overs have different bowlers.
Example case 2: There is no valid assignment in which each of $4$ players bowls at most $1$ over out of $5$.

Difficulty: EASY
Tags: Mathematics

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
t = int(input())
for i in range(t):
	(n, k, l) = map(int, input().split())
	if k * l < n:
		print(-1)
	elif k == 1 and n > 1:
		print(-1)
	else:
		i = 0
		for t in range(n):
			if i == k:
				i = 1
			else:
				i = i + 1
			print(i, end=' ')
	print('')


for _ in range(int(input())):
	(N, K, L) = (int(i) for i in input().split(' '))
	if N / K > L or (K == 1 and N != K):
		print(-1)
	else:
		noOfSessions = N // K + 1
		bowlerLst = list(range(1, K + 1))
		totalOvers = (bowlerLst * noOfSessions)[:N]
		print(*totalOvers)


for _ in range(int(input())):
	(n, k, l) = map(int, input().split())
	if k * l < n or (n > 1 and k == 1):
		print(-1)
	else:
		if k >= n:
			arr = [i for i in range(1, n + 1)]
		else:
			arr = [i for i in range(1, k + 1)]
			arr = arr * (n // k)
			t = n % k
			arr += arr[0:t]
		for i in range(n):
			print(arr[i], end=' ')
		print()


for t in range(int(input())):
	(n, k, l) = map(int, input().split())
	(a, m) = ([], 1)
	if n > k * l or (n == 2 and k == 1):
		print(-1)
	else:
		for i in range(n):
			ans = m % k + 1
			a.append(ans)
			if m == k:
				m = 1
			else:
				m += 1
	print(*a, sep=' ')


t = int(input())
while t > 0:
	val = str(input()).split(' ')
	n = int(val[0])
	k = int(val[1])
	l = int(val[2])
	if n > k * l or (n > 1 and k == 1):
		print(-1)
	else:
		i = 1
		for a in range(n):
			if i > k:
				i = 1
			print(i, end=' ')
			i += 1
		print()
	t -= 1


for _ in range(int(input())):
	(N, K, L) = map(int, input().split())
	if K * L < N:
		print(-1)
	elif K == 1 and N > 1:
		print(-1)
	else:
		s = 1
		for i in range(1, N + 1):
			if s > K:
				s = 1
				print(s, end=' ')
			else:
				print(s, end=' ')
			s = s + 1
	print('')


for tt in range(int(input())):
	(n, k, l) = list(map(int, input().split()))
	o = n // k
	if k == 1:
		if n > 1:
			print(-1)
		else:
			print(1)
		continue
	if n % k > 0:
		o += 1
	if o > l:
		print(-1)
		continue
	if n % k > 0:
		o -= 1
	l = []
	for i in range(n):
		l.append(i % k + 1)
	print(*l)


for _ in range(int(input())):
	(n, k, limit) = map(int, input().split())
	l = [0] * n
	players = [i for i in range(1, k + 1)]
	(p1, cnt) = (0, 0)
	while cnt < n:
		l[cnt] = players[p1]
		p1 = (p1 + 1) % len(players)
		cnt = cnt + 1
	for i in range(k):
		if players[i] == 0 or l.count(players[i]) > limit:
			print(-1)
			break
	else:
		for i in range(n - 1):
			if l[i] == l[i + 1]:
				print(-1)
				break
		else:
			print(*l)


t = int(input())
for _ in range(t):
	(n, k, l) = map(int, input().split())
	li = []
	i = 1
	while len(li) != n:
		if k * l < n or (n > 1 and k == 1):
			print(-1)
			break
		elif i == k + 1:
			i = 1
		else:
			li.append(i)
			i += 1
	print(*li, sep=' ')


for _ in range(int(input())):
	(n, k, l) = list(map(int, input().strip().split()))
	if k * l < n:
		print(-1)
		continue
	if k == 1 and n > 1:
		print(-1)
		continue
	for i in range(n):
		print(i % k + 1, end=' ')
	print()


for _ in range(int(input())):
	(n, k, l) = map(int, input().split())
	if k == 1:
		if n == 1:
			print(1)
		else:
			print(-1)
	elif k * l >= n or (k == 1 and n == 1):
		res = []
		j = 0
		for i in range(n):
			j += 1
			res.append(j)
			if j == k:
				j = 0
		print(*res)
	else:
		print(-1)


def bowlingStrategy(totalOvers, totalPlayers, OversPerPlayer):
	if totalOvers > totalPlayers * OversPerPlayer or (totalPlayers == 1 and totalOvers > 1):
		print('-1')
	else:
		for i in range(totalOvers):
			print(1 + i % totalPlayers, end=' ')
	print()
	return None
for _ in range(int(input())):
	(n, k, l) = map(int, input().split())
	bowlingStrategy(n, k, l)


for t in range(int(input())):
	(a, b, c) = map(int, input().split())
	if b == 1 and a > 1:
		print(-1)
	elif a > b * c:
		print(-1)
	else:
		for i in range(a):
			print(i % b + 1, end=' ')
		print()


for _ in range(int(input())):
	(N, K, L) = map(int, input().split())
	if K * L < N:
		print(-1)
	elif K == 1 and N > 1:
		print(-1)
	else:
		l = []
		for i in range(K):
			l.append(i + 1)
		l = l * L
		print(*l[:N])


for _ in range(int(input())):
	(n, k, l) = map(int, input().split())
	if k * l < n or (k == 1 and n > 1):
		print(-1)
	else:
		while l > 0:
			if n >= k:
				for i in range(1, k + 1):
					print(i, end=' ')
				n = n - k
			else:
				for i in range(1, n + 1):
					print(i, end=' ')
				break
			l = l - 1
		print('')


for _ in range(int(input())):
	(n, k, l) = map(int, input().split())
	if k * l < n or (k == 1 and n > 1):
		print(-1)
	else:
		value = 1
		lt = []
		for i in range(n):
			lt.append(value)
			if (i + 1) % k == 0:
				value = 1
				continue
			value += 1
		print(*lt)


for _ in range(int(input())):
	(N, K, L) = map(int, input().split())
	total = K * L
	available = list(range(1, K + 1)) * L
	last = None
	if total < N:
		print(-1)
	elif K == 1 and N > 1:
		print(-1)
	else:
		for x in range(N):
			if last != available[x]:
				print(available[x], end=' ')
		print('\n', end='')


tests = int(input())
for i in range(tests):
	(n, k, l) = map(int, input().split())
	if k * l < n or (n > 1 and k == 1):
		print(-1)
	else:
		ans = [i for i in range(1, k + 1)] * l
		print(*ans[:n])


t = int(input())
for uvgjv in range(t):
	(n, k, l) = map(int, input().split())
	if k * l < n:
		print(-1)
		continue
	if k == 1 and n != 1:
		print(-1)
		continue
	c = 0
	i = 1
	while c < n:
		if i > k:
			i = 1
		print(i, end=' ')
		c += 1
		i += 1
	print('')


for i in range(int(input())):
	(N, K, L) = map(int, input().split())
	if K == 1:
		if N == 1:
			print(1)
		else:
			print(-1)
	elif K * L >= N or (K == 1 and N == 1):
		l = []
		c = 0
		for i in range(N):
			c += 1
			l.append(c)
			if c == K:
				c = 0
		print(*l)
	else:
		print(-1)


T = int(input())
for i in range(T):
	(N, K, L) = map(int, input().split())
	if K * L < N:
		print(-1)
	elif K == 1 and N > 1:
		print(-1)
	else:
		for j in range(N):
			print(j % K + 1, end=' ')
		print()


for t in range(int(input())):
	(n, k, l) = map(int, input().split())
	if l * k < n:
		print(-1)
		continue
	x = n // k
	y = n % k
	if k == 1 and n > 1:
		print(-1)
	else:
		for i in range(x):
			for j in range(1, k + 1):
				print(j, end=' ')
		if y != 0:
			for i in range(1, y + 1):
				print(i, end=' ')
	print()


t = int(input())
for t in range(t):
	(n, k, l) = [int(i) for i in input().split()]
	arr = [int(i) for i in range(1, k + 1)]
	if n > k * l:
		print(-1)
	elif k == 1 and n > 1:
		print(-1)
	else:
		s = []
		for i in range(n):
			s.append(str(arr[i % k]))
		print(' '.join(s))


for i in range(int(input())):
	(N, K, L) = list(map(int, input().split()))
	A = []
	P = K
	if N > K * L or (N > 1 and K == 1):
		print(-1)
	else:
		for j in range(N):
			if K - j == 0:
				K += P
			A.append(K - j)
		print(*A)


for _ in range(int(input())):
	(N, K, L) = map(int, input().split())
	arr = []
	if K * L < N or (K == 1 and N > 1):
		print(-1)
		continue
	for j in range(1, L + 1):
		for i in range(1, K + 1):
			if N > 0:
				arr.append(i)
				N -= 1
	print(*arr)


import math
for t_c in range(int(input())):
	(n, k, l) = map(int, input().split())
	if n > k * l or (k == 1 and n > 1):
		print('-1')
	else:
		count = 1
		for i in range(n):
			if count == k + 1:
				count = 1
			print(count, end=' ')
			count += 1
		print('\n')


T = int(input())
for _ in range(0, T):
	(n, k, l) = map(int, input().split())
	if k * l < n:
		print(-1)
	elif k == 1 and n > 1:
		print(-1)
	elif k == 1 and n == 1:
		print(1)
	else:
		c = n
		for i in range(0, n, k):
			for w in range(0, k):
				if c == 0:
					break
				else:
					print(w + 1, end=' ')
					c -= 1
	print()


def solve(n, k, l):
	if k == 1 and n > 1:
		return -1
	if k * l >= n:
		res = []
		c = 0
		for i in range(n):
			c += 1
			res.append(c)
			if c == k:
				c = 0
		return res
	return -1
for _ in range(int(input())):
	(n, k, l) = map(int, input().split())
	ans = solve(n, k, l)
	if ans == -1:
		print(-1)
	else:
		print(*ans)


for _ in range(int(input())):
	(N, K, L) = input().split(' ')
	(N, K, L) = (int(N), int(K), int(L))
	if K * L < N or (K == 1 and N > 1):
		print(-1)
	else:
		print(*[int(i % K) + 1 for i in range(N)])


for _ in range(int(input())):
	(n, k, l) = map(int, input().split())
	j = k * l
	(s, t, l1) = (0, 1, [])
	if j < n or (k == 1 and n != 1):
		print(-1)
	else:
		while s < n:
			l1.append(t)
			s += 1
			t += 1
			if t > k:
				t = 1
		print(*l1)


t = int(input())
while t > 0:
	(n, k, l) = map(int, input().split())
	p = 0
	if k * l < n:
		print(-1)
	elif k == 1 and n > 1:
		print(-1)
	else:
		i = 0
		while i < n - 1:
			print(i % k + 1, end=' ')
			i += 1
		print(i % k + 1)
	t -= 1


for i in range(int(input())):
	(n, k, l) = map(int, input().split(' '))
	di = {}
	if k * l < n or (k == 1 and n > 1):
		print(-1)
	else:
		for i in range(1, k + 1):
			di[i] = 0
		sum = 0
		while sum < n:
			for i in range(1, k + 1):
				if di[i] <= l and sum < n:
					sum += 1
					print(i, end=' ')
					di[i] += 1
	print()


t = int(input())
for _ in range(t):
	ans = -1
	(n, l, k) = input().split()
	n = int(n)
	l = int(l)
	k = int(k)
	if k * l >= n and (l != 1 or n == 1):
		i = 1
		j = 1
		while i <= n:
			if j <= l:
				print(j, end=' ')
			else:
				j = 1
				print(j, end=' ')
			j = j + 1
			i = i + 1
	else:
		print(ans, end='')
	print()


for _ in range(int(input())):
	(n, k, l) = list(map(int, input().split()))
	if k * l < n or (k == 1 and n > 1):
		print(-1)
	else:
		d = 1
		for i in range(1, n + 1):
			if d > k:
				d = 1
			print(d, end=' ')
			d += 1
		print()


t = int(input())
for i in range(t):
	(n, k, l) = list(map(int, input().split()))
	(m, v) = ([], [])
	for i in range(1, n + 1):
		v.append(i)
	if n > k * l or (k == 1 and n > 1):
		print(-1)
	else:
		for i in range(n):
			m.append(v[i % k])
		print(*m)


try:
	for _ in range(int(input())):
		(n, k, l) = map(int, input().split())
		if k * l < n or (k == 1 and n > 1):
			print(-1)
		else:
			for i in range(n):
				print(i % k + 1, end=' ')
			print()
except Exception as e:
	raise e


T = int(input())

def algo():
	(N, K, L) = map(int, input().strip().split(' '))
	if K * L < N:
		print(-1)
	elif K == 1 and N > 1:
		print(-1)
	else:
		i = 0
		while i < N - 1:
			print(i % K + 1, end=' ')
			i += 1
		print(i % K + 1)
for i in range(T):
	algo()


for i in range(int(input())):
	(n, k, l) = map(int, input().split(' '))
	x = 1
	if k * l < n or (n > 1 and k == 1):
		print('-1')
		continue
	else:
		for i in range(n):
			print(x, end=' ')
			x += 1
			if x == k + 1:
				x = 1
	print()


for i in range(int(input())):
	(n, k, l) = map(int, input().split())
	s = []
	if k * l < n:
		print(-1)
	elif k == 1 and n > 1:
		print(-1)
	else:
		t = 1
		for i in range(n):
			if t > k:
				t = 1
				s.append(t)
			else:
				s.append(t)
			t = t + 1
	print(*s)


t = int(input())
for _ in range(t):
	(n, k, l) = map(int, input().split(' '))
	if k == 1 and n > 1 or k * l < n:
		print(-1)
	else:
		s = ''
		if n >= k:
			c = 0
			for i in range(n):
				if c == k:
					c = 0
				c += 1
				s += str(c) + ' '
		else:
			for i in range(1, n + 1):
				s += str(i) + ' '
		print(s)


for _ in range(int(input())):
	(over, players, num) = map(int, input().split())
	if players == 1 and over != 1 or players * num < over:
		print(-1)
		continue
	else:
		i = 0
		for t in range(over):
			if i == players:
				i = 1
			else:
				i = i + 1
			print(i, end=' ')
	print('')


for _ in range(int(input())):
	(n, k, l) = map(int, input().split())
	a = []
	ans = []
	for i in range(1, k + 1):
		a.append(i)
	if k * l < n:
		print(-1)
	elif n == 1 and k == 1:
		print(1)
	elif n > 1 and k == 1:
		print(-1)
	else:
		a = a * l
		ans = a[:n]
		print(*ans)


t = int(input())
for i in range(t):
	(n, k, l) = map(int, input().split())
	if k * l < n or (k == 1 and n > 1):
		print(-1)
	else:
		c = 1
		for i in range(n):
			print(c, end=' ')
			c += 1
			if c == k + 1:
				c = 1
		print()


t = int(input())
for _ in range(0, t):
	(n, k, l) = map(int, input().split())
	if k == 1:
		if n > 1:
			print(-1)
			continue
	if n > k * l:
		print(-1)
		continue
	for j in range(n // k):
		for i in range(1, k + 1):
			print(i, end=' ')
	x = n - n // k * k
	for i in range(1, x + 1):
		print(i)


for i in range(int(input())):
	(n, k, l) = map(int, input().split())
	d = []
	if k == 1 and n > 1:
		print(-1)
		continue
	if k * l >= n:
		m = 1
		for j in range(n):
			d.append(m)
			if m == k:
				m = 1
			else:
				m += 1
		print(*d)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	(n, k, l) = map(int, input().split())
	a = []
	if k * l >= n:
		if k == 1 and n > 1:
			a.append(-1)
		else:
			for i in range(1, n + 1):
				if i % k == 0:
					a.append(k)
				else:
					a.append(i % k)
	else:
		a.append(-1)
	print(*a)


for _ in range(int(input())):
	(n, k, l) = map(int, input().split())
	if l * k < n:
		print(-1)
	elif k == 1:
		if n > 1:
			print(-1)
		else:
			print(1)
	else:
		i = 0
		while i < n:
			print(i % k + 1, end=' ')
			i += 1
		print()


for _ in range(int(input())):
	(n, k, l) = list(map(int, input().split()))
	ans = []
	if k == 1 and n > 1:
		print(-1)
	elif n <= k * l:
		ans = []
		while len(ans) < n:
			for i in range(1, min(n - len(ans) + 1, k + 1)):
				ans.append(str(i))
		print(' '.join(ans[:n]))
	else:
		print(-1)


for _ in range(int(input())):
	(n, k, l) = map(int, input().split())
	if k * l < n:
		print(-1)
	elif k == 1:
		if n == 1:
			print(1)
		else:
			print(-1)
	else:
		s = list(range(1, k + 1))
		ans = s * (n // k) + s[:n % k]
		print(*ans)


for i in range(int(input())):
	(N, K, L) = map(int, input().split())
	l = []
	if N > K * L or (N > 1 and K == 1):
		print(-1)
	else:
		for j in range(1, K + 1):
			l.append(j)
	z = l * L
	print(*z[:N])


t = int(input())
while t > 0:
	(n_overs, k_bowlers, l_atmost) = [int(i) for i in input().split(' ')]
	if n_overs > k_bowlers * l_atmost:
		print('-1')
	elif k_bowlers == 1 and n_overs != 1:
		print('-1')
	else:
		cur = 0
		while n_overs > 0:
			print(cur + 1, end=' ')
			cur = (cur + 1) % k_bowlers
			n_overs -= 1
		print()
	t -= 1


for i in range(int(input())):
	(overs, players, maxovers) = map(int, input().split())
	j = 0
	bowled = 0
	num = 1
	loop = 0
	list1 = []
	while loop < maxovers:
		if bowled == overs:
			break
		if num > players:
			num = 1
			loop += 1
		list1.append(num)
		bowled += 1
		num += 1
	if players * maxovers < overs:
		print(-1)
	elif players == 1 and overs > 1:
		print(-1)
	else:
		for z in list1:
			print(z, end=' ')
	print('')


n = int(input())
testCases = []
for i in range(n):
	testCases.append(list(map(int, input().split())))
for case in testCases:
	temp = []
	if case[1] == 1 and case[0] == 1:
		print(1)
	elif case[1] * case[2] >= case[0] and case[1] >= 2:
		for i in range(1, case[0] + 1):
			if i % case[1] == 0:
				temp.append(str(case[1]))
			else:
				temp.append(str(i % case[1]))
		print(' '.join(temp))
	else:
		print(-1)


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	if y * z < x or (y == 1 and x > 1):
		print(-1)
	else:
		s = []
		f = 1
		for i in range(x):
			if f == y + 1:
				f = 1
			s.append(str(f))
			f += 1
		print(' '.join(s))


t = int(input())
for _ in range(t):
	(n, k, l) = map(int, input().split())
	j = 1
	if k * l < n or (n > 1 and k == 1):
		print('-1')
		continue
	else:
		for i in range(n):
			print(j, end=' ')
			j += 1
			if j == k + 1:
				j = 1
	print()


t = int(input())
while t:
	(n, k, l) = map(int, input().split())
	if k * l < n:
		print(-1)
	elif k == 1 and n > 1:
		print(-1)
	else:
		(a, b) = divmod(n, k)
		l = [i for i in range(1, k + 1)]
		print(*a * l + l[:b])
	t -= 1


t = int(input())
while t > 0:
	(n, k, l) = map(int, input().split())
	l1 = []
	if k * l < n:
		print('-1')
	elif n > 1 and k == 1:
		print('-1')
	else:
		o = 1
		for i in range(n):
			l1.append(o)
			o += 1
			if o > k:
				o = 1
		print(*l1)
	t -= 1


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	if b == 1 and a != 1 or b * c < a:
		print(-1)
	else:
		l = list(range(1, b + 1))
		nl = l.copy()
		while len(nl) < a:
			nl.extend(l)
		print(*nl[:a], sep=' ')