2^k teams participate in a playoff tournament. The tournament consists of 2^k - 1 games. They are held as follows: first of all, the teams are split into pairs: team 1 plays against team 2, team 3 plays against team 4 (exactly in this order), and so on (so, 2^{k-1} games are played in that phase). When a team loses a game, it is eliminated, and each game results in elimination of one team (there are no ties). After that, only 2^{k-1} teams remain. If only one team remains, it is declared the champion; otherwise, 2^{k-2} games are played: in the first one of them, the winner of the game "1 vs 2" plays against the winner of the game "3 vs 4", then the winner of the game "5 vs 6" plays against the winner of the game "7 vs 8", and so on. This process repeats until only one team remains.

After the tournament ends, the teams are assigned places according to the tournament phase when they were eliminated. In particular:

  * the winner of the tournament gets place 1; 
  * the team eliminated in the finals gets place 2; 
  * both teams eliminated in the semifinals get place 3; 
  * all teams eliminated in the quarterfinals get place 5; 
  * all teams eliminated in the 1/8 finals get place 9, and so on. 



For example, this picture describes one of the possible ways the tournament can go with k = 3, and the resulting places of the teams:

<image>

After a tournament which was conducted by the aforementioned rules ended, its results were encoded in the following way. Let p_i be the place of the i-th team in the tournament. The hash value of the tournament h is calculated as h = (∑ _{i=1}^{2^k} i ⋅ A^{p_i}) mod 998244353, where A is some given integer.

Unfortunately, due to a system crash, almost all tournament-related data was lost. The only pieces of data that remain are the values of k, A and h. You are asked to restore the resulting placing of the teams in the tournament, if it is possible at all.

Input

The only line contains three integers k, A and h (1 ≤ k ≤ 5; 100 ≤ A ≤ 10^8; 0 ≤ h ≤ 998244352).

Output

If it is impossible to find any placing of the teams that is consistent with the data you have, print one integer -1.

Otherwise, print 2^k integers, where i-th integer should be equal to p_i (the place of the i-th team). Note that your answer should be consistent with one of the possible ways the tournament could go, and note that the initial structure of the tournament is fixed (for example, teams 1 and 2 always play in the first phase of the tournament against each other). If there are multiple ways to restore the places of the teams which are consistent with the data you have, print any of them.

Examples

Input


3 1337 75275197


Output


5 3 5 2 1 5 5 3 


Input


2 100 5040100


Output


1 3 3 2 


Input


2 100 7020100


Output


-1

Note

The tournament for the first example is described in the statement.

For the third example, the placing [1, 2, 3, 3] (team 1 gets place 1, team 2 gets place 2, teams 3 and 4 get place 3) could result in a hash value of 7020100 with A = 100, but no tournament can result in such placing since teams 1 and 2 play against each other in the semifinals, so they cannot get two first places.

Difficulty: VERY_HARD
Tags: String algorithms

Bit manipulation

Implementation

Complete search
Skill types: Bit manipulation

Complete search

Starter code:

Solutions:
import sys

def pr(x):
	sys.stdout.write(str(x) + '\n')

def inp():
	return sys.stdin.readline()
M = 998244353
(k, a, h) = [int(i) for i in inp().split()]
pp = [[], [2], [3, 2], [5, 3, 2], [9, 5, 3, 2], [17, 9, 5, 3, 2]]
pa = [a ** i % M for i in pp[k]]
rgs = [[], [[1, 3]], [[4, 7], [1, 5]], [[16, 21], [6, 13], [1, 9]], [[64, 73], [28, 41], [10, 25], [1, 17]], [[256, 273], [120, 145], [52, 81], [18, 49], [1, 33]]]
rg = rgs[k]
xa = {}
for i in range(1, (1 << k) + 1):
	xa[i * a % M] = i
r = [0] * (k + 1)

def dfs(n, num):
	if n == k:
		x = (h + M - num) % M
		if x in xa:
			r[n] = xa[x]
			if sum(r) == sum(range(1, (1 << k) + 1)):
				return True
	else:
		for i in range(rg[n][0], rg[n][1]):
			r[n] = i
			if dfs(n + 1, (num + i * pa[n]) % M):
				return True
		return False
if not dfs(0, 0):
	pr(-1)
	sys.exit()
if sum(r) != sum(range(1, (1 << k) + 1)):
	pr(-1)
	sys.exit()
res = [pp[k][0]] * (1 << k)
res[r[-1] - 1] = 1
res[r[-2] - 1] = 2
if (r[-1] - 1) // 1 << k - 1 == (r[-2] - 1) // 1 << k - 1:
	pr(-1)
	sys.exit()
for i in range(k - 2, 0, -1):
	t = [1] * (1 << k - i)
	for j in range(1 << k):
		if res[j] != pp[k][0]:
			t[j // (1 << i)] = 0
	r[i] -= sum(((j * 1 << i) + 1 for j in range(len(t)) if t[j]))
	for j in range(len(t)):
		if t[j]:
			x = min(r[i], (1 << i) - 1)
			r[i] -= x
			res[j * (1 << i) + x] = pp[k][i]
	if r[i]:
		pr(-1)
		sys.exit()
print(' '.join((str(i) for i in res)))


(k, A, h) = map(int, input().split())
team = 1 << k
mod = 998244353
POW = [1]
for i in range(100):
	POW.append(POW[-1] * A % mod)
ANS = [(1 << k - 1) + 1] * (team // 2)
X = tuple([i for i in range(team // 2)])
ALLLIST = []

def half_all(ANS, X, Y, i):
	if i == 0:
		ALLLIST.append(tuple(ANS))
		return ANS
	if X == tuple():
		X = Y
		Y = tuple()
		half_all(ANS, X, Y, i - 1)
		return
	X = list(X)
	ANS = list(ANS)
	p = X.pop()
	q = X.pop()
	ANS[p] = ANS[p] // 2 + 1
	half_all(tuple(ANS), tuple(X), Y + (p,), i)
	ANS[p] = ANS[p] * 2 - 1
	ANS[q] = ANS[q] // 2 + 1
	half_all(tuple(ANS), tuple(X), Y + (q,), i)
half_all(ANS, X, tuple(), k - 1)
SCORE01 = [0] * len(ALLLIST)
SCORE02 = [0] * len(ALLLIST)
SCORE11 = [0] * len(ALLLIST)
SCORE12 = [0] * len(ALLLIST)
for i in range(len(ALLLIST)):
	LIST = ALLLIST[i]
	sc01 = sc02 = sc11 = sc12 = 0
	for j in range(team // 2):
		if LIST[j] != 2:
			sc01 += (j + 1) * POW[LIST[j]] % mod
			sc02 += (j + 1) * POW[LIST[j]] % mod
			sc01 %= mod
			sc02 %= mod
			sc11 += (j + 1 + team // 2) * POW[LIST[j]] % mod
			sc12 += (j + 1 + team // 2) * POW[LIST[j]] % mod
			sc11 %= mod
			sc12 %= mod
		else:
			sc01 += (j + 1) * POW[1] % mod
			sc02 += (j + 1) * POW[2] % mod
			sc01 %= mod
			sc02 %= mod
			sc11 += (j + 1 + team // 2) * POW[1] % mod
			sc12 += (j + 1 + team // 2) * POW[2] % mod
			sc11 %= mod
			sc12 %= mod
	SCORE01[i] = sc01
	SCORE02[i] = sc02
	SCORE11[i] = sc11
	SCORE12[i] = sc12
SCSET11 = set(SCORE11)
SCSET12 = set(SCORE12)
for i in range(len(ALLLIST)):
	if (h - SCORE01[i]) % mod in SCSET12:
		k = SCORE12.index((h - SCORE01[i]) % mod)
		LANS = list(ALLLIST[i] + ALLLIST[k])
		for j in range(len(LANS)):
			if LANS[j] == 2:
				LANS[j] = 1
				break
		print(*LANS)
		break
	if (h - SCORE02[i]) % mod in SCSET11:
		k = SCORE11.index((h - SCORE02[i]) % mod)
		LANS = list(ALLLIST[i] + ALLLIST[k])
		for j in range(len(LANS) - 1, -1, -1):
			if LANS[j] == 2:
				LANS[j] = 1
				break
		print(*LANS)
		break
else:
	print(-1)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
from collections import deque
for _ in range(int(input()) if not True else 1):
	(k, A, h) = map(int, input().split())
	mod = 998244353

	def solve(a, k, f=False, finding=False):
		total = 1 << k
		hashes = {}
		bx = [[set(), set()] for i in range(16)]
		for i in range(1 << total - 1):
			cur = 17 if f else (total >> 1) + 1
			left = (cur - 1) // (1 + f)
			b = deque(a)
			hash = 0
			ans = [0] * total
			for j in range(total - 1):
				(x, y) = (b.popleft(), b.popleft())
				if i & 1 << j:
					hash = (hash + x * pow(A, cur, mod)) % mod
					ans[x - a[0]] = cur
					b += [y]
				else:
					hash = (hash + y * pow(A, cur, mod)) % mod
					ans[y - a[0]] = cur
					b += [x]
				left -= 1
				if not left:
					cur >>= 1
					cur += 1
					left = (cur - 1) // (1 + f)
			if not f:
				hash = (hash + b[0] * A) % mod
				ans[b[0] - a[0]] = 1
				if hash == h:
					print(*ans)
					quit()
			elif not finding:
				bx[b[0] - a[0]][1].add((hash + b[0] * A) % mod)
				bx[b[0] - a[0]][0].add((hash + b[0] * A * A) % mod)
			elif b[0] == finding[0]:
				jj = [(hash + b[0] * A * A) % mod, (hash + b[0] * A) % mod][finding[1]]
				if jj == finding[2]:
					return ans
		if not f:
			print(-1)
			quit()
		return bx
	if k <= 4:
		solve(list(range(1, (1 << k) + 1)), k)
		quit()
	pp = list(range(1, (1 << k) + 1))
	pp1 = pp[:16]
	pp2 = pp[16:]
	bx1 = solve(pp1, k - 1, True)
	bx2 = solve(pp2, k - 1, True)
	pos = False
	for i in pp1:
		for j in pp2:
			for l1 in bx1[i - 1][1]:
				if (h - l1) % mod in bx2[j - 17][0]:
					l2 = (h - l1) % mod
					ans = solve(pp1, k - 1, True, (i, 1, l1)) + solve(pp2, k - 1, True, (j, 0, l2))
					ans[i - 1] = 1
					ans[j - 1] = 2
					print(*ans)
					quit()
			for l1 in bx1[i - 1][0]:
				if (h - l1) % mod in bx2[j - 17][1]:
					l2 = (h - l1) % mod
					ans = solve(pp1, k - 1, True, (i, 0, l1)) + solve(pp2, k - 1, True, (j, 1, l2))
					ans[i - 1] = 2
					ans[j - 1] = 1
					print(*ans)
					quit()
	print(-1)


from collections import defaultdict
import sys
input = sys.stdin.readline

def f(u, v, s0):
	t0 = []
	if v == 2:
		for x1 in range(1, pk // 2 + 1):
			if not x1 in s0:
				continue
			for x2 in range(pk // 2 + 1, pk + 1):
				if not x2 in s0:
					continue
				if x1 + x2 == u:
					t0.append((x1, x2))
					break
	elif v == 4:
		(pk1, pk2, pk3) = (pk // 4, pk // 4 * 2, pk // 4 * 3)
		for x1 in range(1, pk1 + 1):
			if not x1 in s0:
				continue
			for x2 in range(pk1 + 1, pk2 + 1):
				if not x2 in s0:
					continue
				for x3 in range(pk2 + 1, pk3 + 1):
					if not x3 in s0:
						continue
					for x4 in range(pk3 + 1, pk + 1):
						if not x4 in s0:
							continue
						if x1 + x2 + x3 + x4 == u:
							t0.append((x1, x2, x3, x4))
							break
	else:
		(pk1, pk2, pk3) = (pk // 8, pk // 8 * 2, pk // 8 * 3)
		(pk4, pk5) = (pk // 8 * 4, pk // 8 * 5)
		(pk6, pk7) = (pk // 8 * 6, pk // 8 * 7)
		for x1 in range(1, pk1 + 1):
			if not x1 in s0:
				continue
			for x2 in range(pk1 + 1, pk2 + 1):
				if not x2 in s0:
					continue
				for x3 in range(pk2 + 1, pk3 + 1):
					if not x3 in s0:
						continue
					for x4 in range(pk3 + 1, pk4 + 1):
						if not x4 in s0:
							continue
						for x5 in range(pk4 + 1, pk5 + 1):
							if not x5 in s0:
								continue
							for x6 in range(pk5 + 1, pk6 + 1):
								if not x6 in s0:
									continue
								for x7 in range(pk6 + 1, pk7 + 1):
									if not x7 in s0:
										continue
									for x8 in range(pk7 + 1, pk + 1):
										if not x8 in s0:
											continue
										if x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 == u:
											t0.append((x1, x2, x3, x4, x5, x6, x7, x8))
											break
	return t0

def check(ans):
	hh = 0
	for i in range(pk):
		hh += (i + 1) * z[xy[ans[i]]]
		hh %= mod
	if hh == h:
		print(*ans)
		exit()
	return

def solve(s):
	ans = [0] * pk
	s0 = set(w)
	for i in range(2):
		if ans[s[i] - 1]:
			return
		s0.remove(s[i])
		ans[s[i] - 1] = x[i]
	t = []
	for i in range(2, k):
		t.append(f(s[i], y[i], s0))
	if len(t) == 0:
		s1 = set()
		for i in range(pk):
			if not ans[i]:
				s1.add(i // 2)
		if len(s1) == pk // 2:
			for i in range(pk):
				if not ans[i]:
					ans[i] = x[-1]
			check(ans)
			for i in range(pk):
				if not ans[i] == x[-1]:
					ans[i] = 0
	elif len(t) == 1:
		t0 = t[0]
		for t00 in t0:
			ok = 1
			s00 = []
			for i in t00:
				if not i in s0:
					ok = 0
					break
				s00.append(i)
				ans[i - 1] = 3
				s0.remove(i)
			if not ok:
				for i in s00:
					ans[i - 1] = 0
					s0.add(i)
			else:
				s1 = set()
				for i in range(pk):
					if not ans[i]:
						s1.add(i // 2)
				if len(s1) == pk // 2:
					for i in range(pk):
						if not ans[i]:
							ans[i] = 5
					check(ans)
					for i in range(pk):
						if not ans[i] == 5:
							ans[i] = 0
	elif len(t) == 2:
		(t0, t1) = (t[0], t[1])
		for t00 in t0:
			ok = 1
			s00 = []
			for i in t00:
				if not i in s0:
					ok = 0
					break
				s00.append(i)
				ans[i - 1] = 3
				s0.remove(i)
			if ok:
				for t11 in t1:
					ok = 1
					s11 = []
					for i in t11:
						if not i in s0:
							ok = 0
							break
						s11.append(i)
						ans[i - 1] = 5
						s0.remove(i)
					if ok:
						s1 = set()
						for i in range(pk):
							if not ans[i]:
								s1.add(i // 2)
						if len(s1) == pk // 2:
							for i in range(pk):
								if not ans[i]:
									ans[i] = 9
							check(ans)
							for i in range(pk):
								if not ans[i] == 9:
									ans[i] = 0
					for i in s11:
						ans[i - 1] = 0
						s0.add(i)
			for i in s00:
				ans[i - 1] = 0
				s0.add(i)
	else:
		(t0, t1, t2) = (t[0], t[1], t[2])
		for t00 in t0:
			ok = 1
			s00 = []
			for i in t00:
				if not i in s0:
					ok = 0
					break
				s00.append(i)
				ans[i - 1] = 3
				s0.remove(i)
			if ok:
				for t11 in t1:
					ok = 1
					s11 = []
					for i in t11:
						if not i in s0:
							ok = 0
							break
						s11.append(i)
						ans[i - 1] = 5
						s0.remove(i)
					if ok:
						for t22 in t2:
							ok = 1
							s22 = []
							for i in t22:
								if not i in s0:
									ok = 0
									break
								s22.append(i)
								ans[i - 1] = 9
								s0.remove(i)
							if ok:
								s1 = set()
								c = 0
								for i in range(pk):
									if not ans[i]:
										c += 1
										s1.add(i // 2)
								if len(s1) == pk // 2:
									for i in range(pk):
										if not ans[i]:
											ans[i] = 17
									check(ans)
									for i in range(pk):
										if not ans[i] == 17:
											ans[i] = 0
							for i in s22:
								ans[i - 1] = 0
								s0.add(i)
					for i in s11:
						ans[i - 1] = 0
						s0.add(i)
			for i in s00:
				ans[i - 1] = 0
				s0.add(i)
	return
(k, a, h) = map(int, input().split())
mod = 998244353
x = [1, 2, 3, 5, 9, 17][:k + 1]
y = [1, 1, 2, 4, 8, 16][:k + 1]
xy = dict()
for i in range(len(x)):
	xy[x[i]] = i
z = [pow(a, i, mod) for i in x]
if k == 1:
	ans = [-1]
	if (z[0] * 1 + z[1] * 2) % mod == h:
		ans = [1, 2]
	elif (z[0] * 2 + z[1] * 1) % mod == h:
		ans = [2, 1]
	print(*ans)
	exit()
pow2 = [1]
for _ in range(100):
	pow2.append(2 * pow2[-1] % mod)
pk = pow2[k]
w = [i for i in range(1, pk + 1)]
b = []
for i in range(k + 1):
	(l, r) = (0, 0)
	c = pk // y[i]
	j = 0
	for _ in range(y[i]):
		l += w[j]
		r += w[-(j + 1)]
		j += c
	b.append([j for j in range(l, r + 1)])
n1 = (k + 1) // 2
n2 = k + 1 - n1
d = defaultdict(lambda : [])
if n1 == 1:
	b0 = b[0]
	z0 = z[0]
	for i in b0:
		h0 = z0 * i % mod
		d[h0].append(tuple([i]))
elif n1 == 2:
	(b0, b1) = (b[0], b[1])
	(z0, z1) = (z[0], z[1])
	for i in b0:
		h0 = z0 * i % mod
		for j in b1:
			h1 = z1 * j % mod + h0
			h1 %= mod
			d[h1].append((i, j))
else:
	(b0, b1, b2) = (b[0], b[1], b[2])
	(z0, z1, z2) = (z[0], z[1], z[2])
	for i in b0:
		h0 = z0 * i % mod
		for j in b1:
			h1 = z1 * j % mod + h0
			h1 %= mod
			for l in b2:
				h2 = z2 * l % mod + h1
				h2 %= mod
				d[h2].append((i, j, l))
if n2 == 1:
	b0 = b[n1]
	z0 = z[n1]
	for i in b0:
		h0 = z0 * i % mod
		if (h - h0) % mod in d:
			for u in d[(h - h0) % mod]:
				s = []
				for v in u:
					s.append(v)
				s.append(i)
				solve(s)
elif n2 == 2:
	(b0, b1) = (b[n1], b[n1 + 1])
	(z0, z1) = (z[n1], z[n1 + 1])
	for i in b0:
		h0 = z0 * i % mod
		for j in b1:
			h1 = z1 * j % mod + h0
			h1 %= mod
			if (h - h1) % mod in d:
				for u in d[(h - h1) % mod]:
					s = []
					for v in u:
						s.append(v)
					s.append(i)
					s.append(j)
					solve(s)
else:
	(b0, b1, b2) = (b[n1], b[n1 + 1], b[n1 + 2])
	(z0, z1, z2) = (z[n1], z[n1 + 1], z[n1 + 2])
	for i in b0:
		h0 = z0 * i % mod
		for j in b1:
			h1 = z1 * j % mod + h0
			h1 %= mod
			for l in b2:
				h2 = z2 * l % mod + h1
				h2 %= mod
				if (h - h2) % mod in d:
					for u in d[(h - h2) % mod]:
						s = []
						for v in u:
							s.append(v)
						s.append(i)
						s.append(j)
						s.append(l)
						solve(s)
print(-1)


MOD = 998244353
(k, A, H) = map(int, input().split())
sgames = 2 ** (k - 1) - 1
steams = 2 ** (k - 1)

def build(wp: int, offset: int):
	pos = {}
	for outcomes in range(2 ** sgames):
		i = 0
		res = 0
		teams = [i for i in range(steams)]
		place = [-1] * steams
		for p in range(k - 1, 0, -1):
			nteams = []
			for (a, b) in zip(teams[::2], teams[1::2]):
				winner = outcomes & 1 << i
				i += 1
				if winner:
					(a, b) = (b, a)
				nteams.append(a)
				place[b] = 2 ** p + 1
			teams = nteams
		assert len(teams) == 1, teams
		place[teams[0]] = wp
		h = 0
		for (i, p) in enumerate(place):
			h = (h + (i + offset + 1) * pow(A, p, MOD)) % MOD
		pos[h] = place
	return pos
(W1, L1) = (build(1, 0), build(2, 0))
(W2, L2) = (build(1, steams), build(2, steams))
for (a, b) in ((W1, L2), (L1, W2)):
	for (h1, p1) in a.items():
		h2 = (H - h1) % MOD
		p2 = b.get(h2)
		if p2 is not None:
			print(*p1 + p2)
			raise SystemExit
print(-1)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = 998244353
(k, A, h) = map(int, input().split())
dic = {}
for i in range(1 << k):
	dic[A * i % M] = i

def fastfrac(a, b, M):
	numb = pow(b, M - 2, M)
	return a % M * (numb % M) % M

def gettot(restk, h, pre, target, modnum, rangenum):
	if restk == 0:
		if h in dic:
			pre.append(dic[h])
			target.append(list(pre[::-1]))
			pre.pop()
		return
	for i in range(rangenum[restk]):
		pre.append(i)
		gettot(restk - 1, (h - modnum[restk] * i) % M, pre, target, modnum, rangenum)
		pre.pop()

def getans(restk, rank, target, pre, effect, ans):
	if restk == 0:
		if effect[0] == target[0]:
			pre[effect[0]] = 1
			ans.append(list(pre))
			pre[effect[0]] = 0
		return
	for b in range(1 << rank[restk] - 1):
		s = bin(b)[2:]
		s = '0' * (rank[restk] - 1 - len(s)) + s
		tot = 0
		for i in range(len(s)):
			tot += effect[2 * i + int(s[i])]
		if tot != target[restk]:
			continue
		pick = []
		nexteffect = []
		for i in range(len(s)):
			pick.append(effect[2 * i + int(s[i])])
			nexteffect.append(effect[2 * i + 1 - int(s[i])])
			pre[pick[-1]] = rank[restk]
		getans(restk - 1, rank, target, pre, nexteffect, ans)
		for p in pick:
			pre[p] = 0
		if len(ans) > 0:
			return

def main(k, A, h):
	status = [1, 1, 2, 4, 8, 16]
	rank = [1, 2, 3, 5, 9, 17]
	modnum = [pow(A, rank[i], M) for i in range(6)]
	n = 1 << k
	dic = {}
	subtract = []
	for i in range(k + 1):
		h -= modnum[i] * status[i]
		h = h % M
	for i in range(k, 1, -1):
		subtract = [(1 << k - i + 1) * status[i] * (status[i] - 1) // 2] + subtract
		h -= modnum[i] * (1 << k - i + 1) * status[i] * (status[i] - 1) // 2
		h = h % M
	subtract = [0, 0] + subtract
	rangenum = [status[i] * (n // status[i] - 1) + 1 for i in range(k + 1)]
	pretot = []
	effect = [i for i in range(1 << k)]
	target = []
	gettot(k, h, pretot, target, modnum, rangenum)
	if not target:
		print(-1)
		return
	ans = []
	pre = [0] * n
	for subtarget in target:
		for i in range(k + 1):
			subtarget[i] += subtract[i]
		getans(k, rank, subtarget, pre, effect, ans)
		if len(ans) > 0:
			break
	if not ans:
		print(-1)
	else:
		print(' '.join(map(str, ans[0])))
main(k, A, h)


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
inf = 10 ** 16
md = 998244353

def cal_all(l, r, top):
	n = r - l - 1
	res = {}
	for bit in range(1 << n):
		tt = list(range(l, r))
		ntt = []
		p = len(tt) + 1
		cur = 0
		for i in range(n):
			t0 = tt.pop()
			t1 = tt.pop()
			if bit >> i & 1:
				(win, lose) = (t0, t1)
			else:
				(win, lose) = (t1, t0)
			cur += lose * pow(a, p, md) % md
			cur %= md
			ntt.append(win)
			if not tt:
				(tt, ntt) = (ntt, tt)
				p = len(tt) + 1
		t = tt[0]
		cur += t * pow(a, top, md) % md
		res[cur % md] = bit
	return res

def team(bit, l, r, top):
	res = [-1] * (r - l)
	tt = list(range(l, r))
	ntt = []
	p = len(tt) + 1
	for i in range(r - l - 1):
		t0 = tt.pop()
		t1 = tt.pop()
		if bit >> i & 1:
			(win, lose) = (t0, t1)
		else:
			(win, lose) = (t1, t0)
		res[lose - l] = p
		ntt.append(win)
		if not tt:
			(tt, ntt) = (ntt, tt)
			p = len(tt) + 1
	t = tt[0]
	res[t - l] = top
	return res

def search(ss, tt, stop, ttop):
	for s in ss.keys():
		if (h - s) % md in tt:
			b1 = ss[s]
			b2 = tt[(h - s) % md]
			return team(b1, 1, 1 + (1 << k - 1), stop) + team(b2, 1 + (1 << k - 1), 1 + (1 << k), ttop)
	return []
(k, a, h) = LI()
ss = cal_all(1, 1 + (1 << k - 1), 1)
tt = cal_all(1 + (1 << k - 1), 1 + (1 << k), 2)
ans = search(ss, tt, 1, 2)
if ans:
	print(*ans)
	exit()
ss = cal_all(1, 1 + (1 << k - 1), 2)
tt = cal_all(1 + (1 << k - 1), 1 + (1 << k), 1)
ans = search(ss, tt, 2, 1)
if ans:
	print(*ans)
else:
	print(-1)


from itertools import product
M = 998244353
(k, A, h) = map(int, input().split())

def play_half(os, lo, lo_win):
	j = 0
	teams = list(range(2 ** (k - 1)))
	places = [0 for _ in teams]
	for i in range(k - 1):
		tt = []
		z = 2 ** (k - 2 - i)
		for r in range(z):
			o = os[j]
			j += 1
			places[teams[r * 2 + o]] = z * 2 + 1
			tt.append(teams[r * 2 + (1 - o)])
		teams = tt
	places[teams[0]] = 1 + (lo != lo_win)
	h = sum(((i + 1 + [len(places), 0][lo]) * pow(A, v, M) for (i, v) in enumerate(places))) % M
	return (h, places)

def find():
	for lo_win in [0, 1]:
		lo = {}
		z = 0
		for p in product(*([0, 1] for _ in range(2 ** (k - 1) - 1))):
			(x, y) = play_half(p, True, lo_win)
			z += 1
			lo[x] = y
		for p in product(*([0, 1] for _ in range(2 ** (k - 1) - 1))):
			(x, y) = play_half(p, False, lo_win)
			if (h - x) % M in lo:
				return ' '.join(map(str, lo[(h - x) % M] + y))
	return -1
print(find())