Student Dima from Kremland has a matrix $a$ of size $n \times m$ filled with non-negative integers.

He wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected integers is strictly greater than zero. Help him!

Formally, he wants to choose an integers sequence $c_1, c_2, \ldots, c_n$ ($1 \leq c_j \leq m$) so that the inequality $a_{1, c_1} \oplus a_{2, c_2} \oplus \ldots \oplus a_{n, c_n} > 0$ holds, where $a_{i, j}$ is the matrix element from the $i$-th row and the $j$-th column.

Here $x \oplus y$ denotes the bitwise XOR operation of integers $x$ and $y$.


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \leq n, m \leq 500$) — the number of rows and the number of columns in the matrix $a$.

Each of the next $n$ lines contains $m$ integers: the $j$-th integer in the $i$-th line is the $j$-th element of the $i$-th row of the matrix $a$, i.e. $a_{i, j}$ ($0 \leq a_{i, j} \leq 1023$). 


-----Output-----

If there is no way to choose one integer from each row so that their bitwise exclusive OR is strictly greater than zero, print "NIE".

Otherwise print "TAK" in the first line, in the next line print $n$ integers $c_1, c_2, \ldots c_n$ ($1 \leq c_j \leq m$), so that the inequality $a_{1, c_1} \oplus a_{2, c_2} \oplus \ldots \oplus a_{n, c_n} > 0$ holds. 

If there is more than one possible answer, you may output any.


-----Examples-----
Input
3 2
0 0
0 0
0 0

Output
NIE

Input
2 3
7 7 7
7 7 10

Output
TAK
1 3 



-----Note-----

In the first example, all the numbers in the matrix are $0$, so it is impossible to select one number in each row of the table so that their bitwise exclusive OR is strictly greater than zero.

In the second example, the selected numbers are $7$ (the first number in the first line) and $10$ (the third number in the second line), $7 \oplus 10 = 13$, $13$ is more than $0$, so the answer is found.

Difficulty: MEDIUM_HARD

Solutions:
(n, m) = map(int, input().split())
le = []
ans = [1] * n
ans1 = []
flag = True
for i in range(n):
	xx = list(map(int, input().split()))
	ans1.append(xx[0])
	if flag:
		f1 = False
		for j in range(m):
			if xx[j] != xx[0]:
				f1 = True
				flag = False
				break
		if f1:
			le = [i, 0, j]
su = 0
for i in range(n):
	su ^= ans1[i]
if su != 0:
	print('TAK')
	print(*ans)
elif le:
	ans[le[0]] = le[2] + 1
	print('TAK')
	print(*ans)
else:
	print('NIE')


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
ans = [1] * n
c = a[0][0]
for i in range(1, n):
	c ^= a[i][0]
if c:
	print('TAK')
	print(*ans)
else:
	flag = False
	for i in range(n):
		if len(set(a[i])) > 1:
			flag = True
			for j in range(m):
				if a[i][j] != a[i][0]:
					ans[i] = j + 1
					break
			break
	if not flag:
		print('NIE')
	else:
		print('TAK')
		print(*ans)


import sys
(n, m) = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(n)]
kek = False
for x in arr:
	for i in range(m - 1):
		if x[i] != x[i + 1]:
			kek = True
val = 0
for i in range(n):
	val ^= arr[i][0]
if val > 0:
	print('TAK')
	print('1 ' * n)
	sys.exit(0)
if not kek and val == 0:
	print('NIE')
	sys.exit(0)
for i in range(n):
	for j in range(m - 1):
		if arr[i][j] != arr[i][j + 1]:
			print('TAK')
			print('1 ' * i + str(j + 2) + ' ' + '1 ' * (n - i - 1))
			sys.exit(0)


import heapq
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7

def main():
	(n, m) = map(int, input().split())
	a = [list(map(int, input().split())) for i in range(n)]
	xor = 0
	for i in range(n):
		xor ^= a[i][0]
	l = [1] * n
	if xor > 0:
		print('TAK')
		print(*l)
		exit()
	for i in range(n):
		for j in range(1, m):
			if xor ^ a[i][j] ^ a[i][0] > 0:
				l[i] = j + 1
				xor ^= a[i][j]
				xor ^= a[i][0]
				if xor > 0:
					print('TAK')
					print(*l)
					exit()
	print('NIE')
main()


(n, m) = list(map(int, input().split()))
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
c = []
q = []
for i in range(n):
	b = -1
	w = 0
	for j in range(m):
		if b == -1:
			if a[i][j] != b:
				b = a[i][j]
				w = j
		elif a[i][j] != b:
			q.append(a[i][j])
			q.append(j + 1)
			q.append(i)
			break
	c.append([b, w + 1])
s = 0
for i in c:
	s ^= i[0]
if s != 0:
	print('TAK')
	for i in c:
		print(i[1], end=' ')
elif q == []:
	print('NIE')
else:
	print('TAK')
	for i in range(n):
		if i == q[2]:
			print(q[1], end=' ')
		else:
			print(c[i][1], end=' ')


from sys import stdin, stdout
for _ in range(1):
	(r, c) = list(map(int, stdin.readline().split()))
	a = [list(map(int, stdin.readline().split())) for _ in range(r)]
	xor = 0
	f = 0
	for i in range(r):
		xor ^= a[i][0]
	if xor > 0:
		print('TAK')
		print(*[1 for i in range(r)])
		continue
	ans = [1 for i in range(r)]
	for i in range(r):
		for j in range(c):
			if a[i][j] != a[i][0]:
				ans[i] = j + 1
				f = 1
				break
		if f:
			break
	if f:
		print('TAK')
		print(*ans)
	else:
		print('NIE')


from functools import reduce

def main():
	(n, m) = list(map(int, input().split()))
	mat = [list(map(int, input().split())) for i in range(n)]
	for i in range(n):
		mat[i] = list(enumerate(mat[i]))
	l = []
	for i in range(n):
		s = set()
		x = []
		for j in range(m):
			if mat[i][j][1] not in s:
				s.add(mat[i][j][1])
				x.append(mat[i][j])
		l.append(x)
	a = 0
	for i in l:
		a ^= i[0][1]
	if a > 0:
		print('TAK')
		print(*[1] * n)
	else:
		(index, val) = (-1, 0)
		for (j, i) in enumerate(l):
			if len(i) > 1:
				index = j
				val = i[1][0] + 1
				break
		if index == -1:
			print('NIE')
		else:
			u = [1] * n
			u[j] = val
			print('TAK')
			print(*u)
main()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
mat = [list(map(int, input().split())) for _ in range(n)]
smat = [set(r) for r in mat]
xor = 0
for i in range(n):
	xor ^= mat[i][0]
if xor > 0:
	print('TAK')
	print(' '.join(map(str, [1] * n)))
	sys.exit(0)
else:
	if all((len(r) == 1 for r in smat)):
		print('NIE')
		sys.exit(0)
	for gr in range(n):
		if len(smat[gr]) > 1:
			break
	for j in range(m):
		if xor ^ mat[gr][0] ^ mat[gr][j] > 0:
			print('TAK')
			inds = [1] * n
			inds[gr] = j + 1
			print(' '.join(map(str, inds)))
			sys.exit(0)


def put():
	return map(int, input().split())
(n, m) = put()
l = []
xor = 0
for i in range(n):
	l.append(list(put()))
	xor ^= l[-1][0]
ans = [1] * n
if xor == 0:
	found = False
	for i in range(n):
		for j in range(1, m):
			if xor ^ l[i][0] ^ l[i][j] != 0:
				ans[i] = j + 1
				found = True
				xor = xor ^ l[i][0] ^ l[i][j]
				break
		if found:
			break
if xor == 0:
	print('NIE')
else:
	print('TAK')
	print(*ans)


import sys
(n, m) = map(int, input().split())
M = []
for i in range(n):
	M.append(list(map(int, input().split())))
result = 0
for i in range(n):
	result = result ^ M[i][0]
if result > 0:
	print('TAK')
	print(*[1 for _ in range(n)])
	return
is_solution_exist = False
row = None
col = None
for i in range(n):
	for j in range(m):
		if M[i][j] != M[i][0]:
			is_solution_exist = True
			row = i
			col = j
			break
	if is_solution_exist:
		break
if is_solution_exist:
	print('TAK')
	result = [1 for _ in range(n)]
	result[row] = col + 1
	print(*result)
else:
	print('NIE')


import sys
(n, m) = map(int, input().split())

def xor(A):
	x = 0
	for a in A:
		x ^= a
	return x
A = [[int(x) for x in input().split()] for _ in range(n)]
I = [0] * n
ref = A[0][0]
if xor((A[i][0] for i in range(n))):
	print('TAK')
	print(*[i + 1 for i in I])
	sys.exit()
else:
	for i in range(n):
		for j in range(m):
			if A[i][0] != A[i][j]:
				I[i] = j
				print('TAK')
				print(*[i + 1 for i in I])
				sys.exit()
print('NIE')


(n, m) = map(int, input().split())
arr = [[int(x) for x in input().split()] for _ in range(n)]
answer = []
for i in range(n):
	answer = [(i, 0)]
	for j in range(1, m):
		if arr[i][0] != arr[i][j]:
			answer.append((i, j))
			break
	if len(answer) > 1:
		break
if len(answer) > 1:
	print('TAK')
	for i in range(2):
		(a, b) = answer[i]
		temp = arr[a][b]
		for j in range(n):
			if a != j:
				temp = temp ^ arr[j][0]
		if temp:
			for j in range(n):
				if a != j:
					print(1, end=' ')
				else:
					print(b + 1, end=' ')
			break
else:
	temp = arr[0][0]
	for i in range(1, n):
		temp = temp ^ arr[i][0]
	if temp:
		print('TAK')
		for i in range(n):
			print(1, end=' ')
	else:
		print('NIE')


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
(rows, cols) = RMI()
matrix = [RMI() for _ in range(rows)]
ans = [0] * rows
xor = 0
for i in range(rows):
	xor ^= matrix[i][0]
for i in range(rows):
	if xor > 0:
		break
	for j in range(cols):
		curr = xor ^ matrix[i][0] ^ matrix[i][j]
		if curr > 0:
			ans[i] = j
			xor = curr
			break
if xor == 0:
	print('NIE')
else:
	print('TAK')
	print(*map(lambda x: x + 1, ans))


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

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

def lm():
	return list(map(int, input().split()))
(n, m) = mi()
matrix = []
for i in range(n):
	matrix.append(lm())
done = 0
good = -1
for i in range(n):
	val = matrix[i][0]
	for j in range(m):
		if not matrix[i][j] == val:
			good = (i, j)
			done = 1
			break
	if done == 1:
		break
start = 0
if good == -1:
	for i in range(n):
		start = start ^ matrix[i][0]
	if start == 0:
		print('NIE')
	else:
		print('TAK')
		out = ['1'] * n
		print(*out)
else:
	answers = []
	for i in range(n):
		start = start ^ matrix[i][0]
	if not start == 0:
		print('TAK')
		out = ['1'] * n
		print(*out)
	else:
		extra = 0
		for i in range(n):
			if not i == good[0]:
				extra = extra ^ matrix[i][0]
				answers.append('1')
			else:
				extra = extra ^ matrix[i][good[1]]
				answers.append(str(good[1] + 1))
		print('TAK')
		print(*answers)


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, m) = map(int, input().split())
	a = [list(map(int, input().split())) for _ in range(n)]
	xor = 0
	for i in a:
		xor ^= i[0]
	ans = [1] * n
	for i in range(n):
		for j in range(m):
			if xor ^ a[i][0] ^ a[i][j]:
				ans[i] = j + 1
				print('TAK')
				print(*ans)
				exit()
	print('NIE')
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')
main()


(n, m) = list(map(int, input().split()))
arr = []
xor = 0
for i in range(n):
	d = list(map(int, input().split()))
	if i == 0:
		xor = d[0]
	else:
		xor ^= d[0]
	arr.append(d)
if xor != 0:
	print('TAK')
	print('1 ' * n)
else:
	ans = [1] * n
	fl = False
	for i in range(n):
		for g in range(1, m):
			if arr[i][g] != arr[i][0]:
				ans[i] = g + 1
				fl = True
				break
		if fl:
			break
	if fl:
		print('TAK')
		print(*ans)
	else:
		print('NIE')


(n, m) = map(int, input().split())
lis = [[int(j) for j in input().split()] for i in range(n)]
x = 0
y = 0
lis1 = []
for i in range(n):
	x = x ^ lis[i][0]
if x != 0:
	print('TAK')
	for i in range(n):
		print(1, end=' ')
else:
	for i in range(n):
		for j in range(1, m):
			if lis[i][j] != lis[i][0]:
				y = 1
				print('TAK')
				for z in lis1:
					print(z, end=' ')
				print(j + 1, end=' ')
				for k in range(n - i - 1):
					print(1, end=' ')
			if y == 1:
				break
		if y == 1:
			break
		else:
			lis1.append(1)
	if y == 0:
		print('NIE')


(m, n) = list(map(int, input().split()))
matrix = [list(map(int, input().split())) for i in range(m)]
c = 0
(x, y) = (0, 0)
dupa = 1
for i in range(m):
	if dupa == 0:
		break
	cur = matrix[i][0]
	for j in range(n):
		if matrix[i][j] != cur:
			x = i
			y = j
			print('TAK')
			c = 1
			dupa = 0
			break
import sys
if c == 0:
	zor = 0
	for i in range(m):
		zor = zor ^ matrix[i][0]
	if zor == 0:
		print('NIE')
		sys.exit(0)
	else:
		print('TAK')
		for k in range(m):
			print(1, end=' ')
		sys.exit(0)
else:
	for i in range(m):
		if i != x:
			print(1, end=' ')
		else:
			a = matrix[x][y]
			b = matrix[x][0]
			sor = 0
			for g in range(m):
				sor = sor ^ matrix[g][0]
			if sor > 0:
				print(0 + 1, end=' ')
			else:
				print(y + 1, end=' ')


(n, m) = map(int, input().split())
a = [0] * 2 ** 10
b = []
t = 0
for i in range(n):
	temp = list(map(int, input().split()))
	b.append(temp)
	t = t ^ temp[0]
if t > 0:
	res = [1] * n
	print('TAK')
	print(*res)
	exit()
else:
	for i in range(n):
		for j in range(m):
			if b[i][j] != b[i][0]:
				res = [1] * i + [j + 1] + [1] * (n - i - 1)
				print('TAK')
				print(*res)
				exit()
print('NIE')


(n, m) = map(int, input().split())
(a, xor, b) = ([], 0, [1] * n)
for i in range(n):
	a.append(list(map(int, input().split())))
	xor = xor ^ a[i][0]
for i in range(n):
	for j in range(m):
		if xor ^ a[i][0] ^ a[i][j] != 0:
			b[i] = j + 1
			print('TAK')
			exit(print(*b))
print('NIE')


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, OrderedDict
import math
import heapq

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
(n, m) = listIn()
mtx = []
ans = [1] * n
for i in range(n):
	a = listIn()
	mtx.append(a)
	if i == 0:
		x = mtx[0][0]
	else:
		x ^= mtx[i][0]
if m == 1:
	if x > 0:
		print('TAK')
		ans = [1] * n
		print(*ans)
	else:
		print('NIE')
	exit(0)
for i in range(n):
	if x > 0:
		break
	for j in range(m):
		if x ^ mtx[i][0] ^ mtx[i][j] > 0:
			ans[i] = j + 1
			x = mtx[i][0] ^ mtx[i][j]
			break
if x > 0:
	print('TAK')
	print(*ans)
else:
	print('NIE')


(x, y) = map(int, input().split())
p = list()
l = [1 for i in range(x)]
a = 0
for i in range(x):
	p.append(list(map(int, input().split())))
	a ^= p[i][0]
if a != 0:
	print('TAK')
	print('1 ' * x)
	exit()
else:
	for i in range(x):
		for j in range(y):
			if p[i][0] ^ p[i][j] != 0:
				print('TAK')
				l[i] += j
				print(*l)
				exit()
print('NIE')


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
b = []
ans = 0
for i in range(n):
	ans ^= a[i][0]
	b.append(1)
if ans != 0:
	print('TAK')
	for i in b:
		print(i, end=' ')
	print()
else:
	check = False
	for i in range(n):
		for j in range(m):
			if a[i][j] != a[i][0]:
				check = True
				b[i] = j + 1
				break
		if check:
			break
	if check:
		print('TAK')
		for i in b:
			print(i, end=' ')
		print()
	else:
		print('NIE')


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
res = [1] * n
isPossible = False
for i in range(n):
	cur = 0
	res = [1] * n
	for j in range(n):
		if i != j:
			cur = cur ^ a[j][0]
	for j in range(m):
		if cur ^ a[i][j] > 0:
			res[i] = j + 1
			isPossible = True
			break
	if isPossible:
		break
if isPossible:
	print('TAK')
	print(' '.join(map(str, res)))
else:
	print('NIE')


from sys import stdin
import math
from copy import deepcopy
from collections import defaultdict

def find_xor(matrix, set_arr, bit):
	ans = []
	index = -1
	for i in range(len(set_arr)):
		(first, second) = set_arr[i]
		if first == True and second == True:
			index = i
			break
	if index != -1:
		xor = 0
		for i in range(len(matrix)):
			if i != index:
				xor ^= matrix[i][0]
				ans.append(1)
			else:
				ans.append(0)
		if xor & 2 ** bit == 0:
			for j in range(m):
				if matrix[index][j] & 2 ** bit != 0:
					ans[index] = j + 1
					return (xor ^ matrix[index][j], ans)
			else:
				ans[index] = 1
				return (xor ^ matrix[index][0], ans)
		else:
			for j in range(m):
				if matrix[index][j] & 2 ** bit == 0:
					ans[index] = j + 1
					return (xor ^ matrix[index][j], ans)
			else:
				ans[index] = 1
				return (xor ^ matrix[index][0], ans)
	else:
		xor = 0
		for i in range(len(matrix)):
			if i != index:
				xor ^= matrix[i][0]
				ans.append(1)
		return (xor, ans)

def check(set_arr):
	for i in set_arr:
		(first, second) = i
		if first == True and second == True:
			return True
	xor = 0
	for i in set_arr:
		(first, second) = i
		if first == True:
			xor ^= 0
		else:
			xor ^= 1
	if xor > 0:
		return True
	else:
		return False
(n, m) = list(map(int, stdin.readline().split()))
matrix = []
for _ in range(n):
	matrix.append(list(map(int, stdin.readline().split())))
set_arr = [[False, False] for x in range(n)]
for i in range(0, 10):
	num = 2 ** i
	set_arr = [[False, False] for x in range(n)]
	for j in range(n):
		for k in range(m):
			if num & matrix[j][k] == 0:
				set_arr[j][0] = True
			else:
				set_arr[j][1] = True
	if check(set_arr):
		(xor, ans) = find_xor(matrix, set_arr, i)
		print('TAK')
		print(*ans)
		exit()
else:
	print('NIE')


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

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

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]), reverse=True)

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

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

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	max_so_far = -sys.maxsize - 1
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(0, size):
		max_ending_here += a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here < 0:
			max_ending_here = 0
			s = i + 1
	return (max_so_far, start, end)

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] >= arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def solve():
	(n, m) = num_input()
	mat = []
	ans = [1] * n
	flag = False
	x = 0
	for i in range(n):
		mat.append(list_input())
		x ^= mat[i][0]
	if x != 0:
		print('TAK')
		print(*ans)
	else:
		indx = -1
		row = 0
		for M in mat:
			for i in range(m):
				if M[0] != M[i]:
					indx = i
					flag = True
					break
			if flag:
				break
			row += 1
		if flag:
			print('TAK')
			ans[row] = indx + 1
			print(*ans)
		else:
			print('NIE')
t = 1
for _ in range(t):
	solve()


line = list(map(int, input().split()))
n = line[0]
m = line[1]
a = [None] * n
sXor = 0
for i in range(n):
	a[i] = list(map(int, input().split()))
	sXor ^= a[i][0]
sol = [1] * n
if sXor != 0:
	print('TAK')
	for i in range(n):
		print(str(sol[i]), end=' ')
else:
	solved = False
	for i in range(n):
		for j in range(1, m):
			if a[i][j] != a[i][0]:
				sol[i] = j + 1
				solved = True
				break
		if solved:
			break
	if solved:
		print('TAK')
		for i in range(n):
			print(str(sol[i]), end=' ')
	else:
		print('NIE')


import sys
(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
x = 0
for r in a:
	x ^= r[0]
ans = [1] * n
for i in range(n):
	for j in range(m):
		if x ^ a[i][0] ^ a[i][j]:
			ans[i] = j + 1
			print('TAK')
			print(*ans)
			sys.exit(0)
print('NIE')


(col, row) = [int(i) for i in input().split()]
array = list()
for i in range(col):
	array.append([int(i) for i in input().split()])
choice = list()
xor = int()
for i in range(col):
	choice.append(str(1))
	xor = xor ^ array[i][0]
if xor == 0:
	for i in range(col):
		current = array[i][0]
		check = False
		for j in range(row):
			if array[i][j] != current:
				choice[i] = str(j + 1)
				print('TAK')
				print(' '.join(choice))
				check = True
				break
		if check:
			break
	if check == False:
		print('NIE')
else:
	print('TAK')
	print(' '.join(choice))


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')

def xor(nums):
	x = 0
	for i in nums:
		x ^= i
	return x
(n, m) = int_array()
a = []
for _ in range(n):
	a.append(int_array())
ans = [0] * n
nums = [None] * n
for i in range(n):
	nums[i] = a[i][ans[i]]
if xor(nums) != 0:
	for i in range(n):
		ans[i] += 1
	print('TAK')
	print(*ans)
	exit()
f = 0
for i in range(n):
	if f:
		break
	x = a[i][0]
	for j in range(1, m):
		if a[i][j] != x:
			f = 1
			ans[i] = j
			break
if f:
	for i in range(n):
		ans[i] += 1
	print('TAK')
	print(*ans)
else:
	print('NIE')


(n, m) = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for _ in range(n)]

def test(a, n, m):
	for i in range(n):
		(_or, _and) = (a[i][0], a[i][0])
		for j in range(m):
			_or |= a[i][j]
			_and &= a[i][j]
		if _or != _and:
			return i
	return -1
t = test(a, n, m)
if t == -1:
	_xor = 0
	for i in range(n):
		_xor ^= a[i][0]
	if _xor > 0:
		print('TAK')
		print(' '.join(('1' for _ in range(n))))
		exit()
else:
	_xor = 0
	for i in range(n):
		if i == t:
			continue
		_xor ^= a[i][0]
	for j in range(m):
		if _xor ^ a[t][j] > 0:
			print('TAK')
			print(' '.join(['1' if k != t else str(j + 1) for k in range(n)]))
			exit()
print('NIE')


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
fl = -1
k = 0
for i in range(n):
	if len(set(a[i])) > 1:
		fl = i
		break
x = a[0][0]
for i in range(n):
	for j in range(m):
		if a[i][j] != x:
			k = 1
			break
if k == 0 and n % 2 == 0 or (k == 0 and a[0][0] == 0):
	exit(print('NIE'))
else:
	ans = [1] * n
	x = 0
	if fl != -1:
		for i in range(n):
			if i != fl:
				x ^= a[i][0]
		for i in range(m):
			if x ^ a[fl][i] > 0:
				ans[fl] = i + 1
				break
	x = 0
	for i in range(n):
		x ^= a[i][ans[i] - 1]
	if x > 0:
		print('TAK')
		print(*ans)
	else:
		print('NIE')


(n, m) = list(map(int, input().split(' ')))
mat = [None for i in range(n)]
for i in range(n):
	mat[i] = list(map(int, input().split(' ')))
tmp_xor = 0
for i in range(n):
	tmp_xor ^= mat[i][0]
if tmp_xor:
	print('TAK')
	for i in range(n):
		print('1 ', end='')
else:
	flag = False
	idx = 0
	val = 0
	for i in range(n):
		for j in range(m):
			if mat[i][j] != mat[i][0]:
				flag = True
				idx = i
				val = j
				break
		if flag:
			break
	if flag:
		print('TAK')
		for i in range(idx):
			print('1', end=' ')
		print(val + 1, end=' ')
		for i in range(idx + 1, n, 1):
			print('1', end=' ')
	else:
		print('NIE')


(n, m) = map(int, input().split())
output = [1] * n
Xor = 0
lis = []
for i in range(n):
	lis2 = list(map(int, input().split()))
	Xor = Xor ^ lis2[0]
	lis.append(lis2)
if Xor != 0:
	print('TAK')
	for i in output:
		print(i, end=' ')
	exit()
for i in range(n):
	element = lis[i][0]
	for j in range(1, m):
		if lis[i][j] != element:
			output[i] = j + 1
			print('TAK')
			for i in output:
				print(i, end=' ')
			exit()
print('NIE')


mat = []
(n, m) = [int(i) for i in input().split()]
xor = 0
res = []
flag = False
for i in range(n):
	mat.append([int(i) for i in input().split()])
	xor = xor ^ mat[len(mat) - 1][0]
	res.append(1)
if xor > 0:
	flag = True
else:
	for i in range(n):
		for j in range(1, m):
			if mat[i][res[i] - 1] != mat[i][j]:
				res[i] = j + 1
				flag = True
				break
		if flag:
			break
if not flag:
	print('NIE')
else:
	print('TAK')
	print(' '.join([str(i) for i in res]))


(n, m) = [int(i) for i in input().split()]
l = [[] for i in range(n)]
for i in range(n):
	l[i] = [int(j) for j in input().split()]
l1 = []
for i in range(n):
	l1.append(l[i][0])
xv = 0
for i in range(n):
	xv = xv ^ l1[i]
if xv > 0:
	print('TAK')
	for k in range(n):
		print(1, end=' ')
	exit(0)
t1 = 0
t2 = 0
for i in range(n):
	t1 = xv
	t1 = t1 ^ l[i][0]
	for j in range(m):
		t2 = t1
		t2 = t2 ^ l[i][j]
		if t2 > 0:
			print('TAK')
			for k in range(n):
				if i == k:
					print(j + 1, end=' ')
				else:
					print(1, end=' ')
			exit(0)
print('NIE')


(n, m) = map(int, input().split())
g = []
r_mult = -1
for i in range(n):
	r = [int(s) for s in input().split()]
	dist = {}
	for (j, v) in enumerate(r):
		if v not in dist:
			dist[v] = j + 1
	r = [(v, dist[v]) for v in dist]
	if len(r) > 1 and r_mult == -1:
		r_mult = i
	g.append(r)
sum0 = 0
has_ans = False
for i in range(n):
	sum0 ^= g[i][0][0]
if sum0 > 0 or r_mult != -1:
	has_ans = True
if has_ans:
	ans = []
	for i in range(n):
		to_app = g[i][0][1]
		if sum0 == 0 and r_mult != -1 and (i == r_mult):
			to_app = g[i][1][1]
		ans.append(to_app)
	print('TAK')
	print(*ans)
else:
	print('NIE')


def main():
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		l.append(list(map(int, input().split())))
	xor = 0
	for i in range(n):
		xor ^= l[i][0]
	pos = [0] * n
	if xor == 0:
		for i in range(n):
			for j in range(m):
				if l[i][j] != l[i][0]:
					pos[i] = j
					print('TAK' + '\n' + ' '.join([str(ch + 1) for ch in pos]))
					return
	if xor == 0:
		print('NIE')
	else:
		print('TAK' + '\n' + ' '.join([str(ch + 1) for ch in pos]))
main()


(n, _) = map(int, input().split())
mtrx = [list(map(int, input().split())) for _ in range(n)]
dri = None
for (i, row) in enumerate(mtrx):
	if len(set(row)) > 1:
		dri = i
		break
if dri is None:
	rez = 0
	for row in mtrx:
		rez ^= row[0]
	if rez:
		print('TAK')
		print(*[1] * n)
	else:
		print('NIE')
	exit(0)
rez = 0
rarr = []
for (i, row) in enumerate(mtrx):
	if i == dri:
		rarr.append(None)
	else:
		rez ^= row[0]
		rarr.append(1)
for (i, v) in enumerate(mtrx[dri]):
	if v ^ rez:
		rarr[dri] = i + 1
		break
print('TAK')
print(*rarr)


from sys import stdin
inp = lambda : stdin.readline().strip()
(n, m) = [int(x) for x in inp().split()]
a = [[] for x in range(n)]
b = [set() for x in range(n)]
flag = False
inPair = []
for i in range(n):
	count = 1
	for j in inp().split():
		a[i].append(int(j))
		b[i].add(int(j))
		if len(b[i]) > 1:
			flag = True
			inPair.append(i)
			inPair.append(count)
		count += 1
xor = a[0][0]
for i in range(1, n):
	xor ^= a[i][0]
if xor > 0:
	print('TAK')
	print('1 ' * n)
elif flag:
	print('TAK')
	for i in range(n):
		if i == inPair[0]:
			print(inPair[1], end=' ')
		else:
			print(1, end=' ')
else:
	print('NIE')


import collections
(m, n) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
b = a[0][0]
ans = [1] * m
for i in range(1, m):
	b = b ^ a[i][0]
for i in range(m):
	for j in range(n):
		if b ^ a[i][0] ^ a[i][j] != 0:
			ans[i] = j + 1
			print('TAK')
			exit(print(*ans))
			break
print('NIE')


def fun():
	(n, m) = (int(x) for x in input().split())
	matrix = []
	answer = 0
	for i in range(n):
		line = [int(x) for x in input().split()]
		answer ^= line[0]
		matrix.append(line)
	if answer > 0:
		print('TAK')
		values = n * [1]
		print(*values)
		return
	else:
		for i in range(n):
			j = 1
			while j < m:
				if matrix[i][j] != matrix[i][0]:
					print('TAK')
					values = []
					for k in range(n):
						if k != i:
							values.append(1)
						else:
							values.append(j + 1)
					print(*values)
					return
				j += 1
		print('NIE')
fun()


(n, m) = map(int, input().split())
grid = []
for i in range(n):
	grid.append(list(map(int, input().split())))
xor = 0
for i in range(n):
	xor ^= grid[i][0]

def find(grid):
	for i in range(n):
		for j in range(1, m):
			if grid[i][j] != grid[i][0]:
				return (i, j)
	return (-1, -1)
if xor == 0:
	(a, b) = find(grid)
	if a == b == -1:
		print('NIE')
	else:
		print('TAK')
		for i in range(n):
			if i == a:
				print(b + 1, end=' ')
			else:
				print(1, end=' ')
else:
	print('TAK')
	print(*[1] * n)


(n, m) = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(n)]
flag = 0
for i in range(n):
	if len(set(s[i])) != 1:
		flag = 1
		break
if flag == 0:
	a = 0
	for j in range(n):
		a = a ^ s[j][0]
	if a == 0:
		print('NIE')
		exit()
	else:
		print('TAK')
		print(' '.join(['1' for i in range(n)]))
		exit()
if flag == 1:
	a = s[i][0]
	for j in range(m):
		if s[i][j] != a:
			b = s[i][j]
			break
	(x, y) = (0, 0)
	for t in range(n):
		x = x ^ s[t][0]
		if t == i:
			y = y ^ s[t][j]
		else:
			y = y ^ s[t][0]
	print('TAK')
	if x != 0:
		print(' '.join(['1' for i in range(n)]))
	else:
		s = ['1' for i in range(n)]
		s[i] = str(j + 1)
		print(' '.join(s))


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
for b in range(10):
	RB = [0] * n
	for j in range(n):
		SCORE = []
		for k in range(m):
			if A[j][k] & 1 << b == 0:
				SCORE.append(0)
			else:
				SCORE.append(1)
		SCORE = sorted(set(SCORE))
		if len(SCORE) == 2:
			print('TAK')
			ANS = [1] * n
			XOR = 0
			for k in range(n):
				if j == k:
					continue
				XOR ^= A[k][0] & 1 << b
			if XOR == 0:
				for k in range(m):
					if A[j][k] & 1 << b != 0:
						ANS[j] = k + 1
						print(*ANS)
						sys.exit()
			else:
				for k in range(m):
					if A[j][k] & 1 << b == 0:
						ANS[j] = k + 1
						print(*ANS)
						sys.exit()
		elif len(SCORE) == 1:
			RB[j] = SCORE[0]
	XOR = 0
	for i in range(n):
		XOR ^= RB[i]
	if XOR == 0:
		continue
	else:
		print('TAK')
		print(*[1] * n)
		sys.exit()
else:
	print('NIE')


from sys import stdin, stdout, setrecursionlimit
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from random import seed, randint
from datetime import datetime
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

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

def def_value():
	return 0
(n, m) = mp()
a = []
ans = []
dual = []
x = 0
for i in range(n):
	r = lmp()
	a.append(r)
	ans.append(1)
	x ^= r[0]
	if len(set(r)) > 1:
		dual.append(i)
if x != 0:
	print('TAK')
	print(*ans)
elif len(dual) > 0:
	xx = a[dual[0]][0]
	for j in range(m):
		if xx != a[dual[0]][j]:
			ans[dual[0]] = j + 1
			break
	print('TAK')
	print(*ans)
else:
	print('NIE')


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 factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

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

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

def main():
	(n, m) = RL()
	arr = []
	for _ in range(n):
		arr.append(RLL())
	res = 0
	for i in range(n):
		res ^= arr[i][0]
	ret = [1] * n
	if res != 0:
		print('TAK')
		print(*ret)
	else:
		tag = False
		for i in range(n):
			for j in range(1, m):
				if arr[i][j] != arr[i][0]:
					ret[i] = j + 1
					tag = True
					break
			if tag:
				print('TAK')
				print(*ret)
				break
		else:
			print('NIE')
main()


(n, m) = list(map(int, input().split()))
a = []
b = []
x = 0
for i in range(n):
	a.append(list(map(int, input().split())))
	x = x ^ a[i][0]
	b.append(len(set(a[i])))
if x != 0:
	c = [1] * n
	print('TAK')
	print(*c)
else:
	d = []
	e = 0
	for i in range(len(b)):
		if b[i] > 1:
			e = 1
			for j in range(m):
				if a[i][j] != a[i][0]:
					c = [i, j + 1]
					break
			break
	if e == 0:
		print('NIE')
	else:
		d = []
		for i in range(n):
			if i == c[0]:
				d.append(c[1])
			else:
				d.append(1)
		print('TAK')
		print(*d)


import operator
from functools import reduce
(n, m) = map(int, input().split())
mat = [list(map(int, input().split())) for _ in range(n)]
yes = any((len(set(s)) > 1 for s in mat))
xor = reduce(operator.xor, [d[0] for d in mat])
if xor > 0:
	yes = True
index = ['1'] * n
if yes and xor == 0:
	for (i, row) in enumerate(mat):
		if len(set(row)) > 1:
			for (j, n) in enumerate(row):
				if n != row[0]:
					index[i] = str(j + 1)
					break
			break
print('TAK' if yes else 'NIE')
if yes:
	print(' '.join(index))


import math
import time
from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from queue import PriorityQueue
import sys
(n, m) = map(int, stdin.readline().split())
grid = []
for _ in range(n):
	grid.append(list(map(int, stdin.readline().split())))
ans = 0
ansL = [1] * n
for i in range(n):
	ans ^= grid[i][0]
if ans != 0:
	print('TAK')
	print(*ansL)
else:
	found = False
	for row in range(n):
		for col in range(1, m):
			if grid[row][col] != grid[row][0]:
				found = True
				ansL[row] = col + 1
				break
		if found:
			break
	if found:
		print('TAK')
		print(*ansL)
	else:
		print('NIE')


(n, m) = map(int, input().split())
matrix = []
for i in range(n):
	line = input().split()
	line = [int(x) for x in line]
	matrix.append(line)
total = 0
res = []
for line in matrix:
	total ^= line[0]
	res.append(1)
if total == 0:
	i = 0
	achei = False
	while i < n and achei == False:
		for j in range(1, m):
			if matrix[i][j] != matrix[i][0]:
				res[i] = j + 1
				achei = True
				break
		i += 1
else:
	achei = True
if achei == False:
	print('NIE')
else:
	print('TAK')
	for r in res:
		print(r, end=' ')
	print()


(n, m) = map(int, input().split())
a = [[int(s) for s in input().split()] for i in range(n)]
ans = [1] * n
x = a[0][0]
for i in range(1, n):
	x ^= a[i][0]
if x:
	print('TAK')
	print(*ans)
else:
	flag = False
	for i in range(n):
		if len(set(a[i])) > 1:
			flag = True
			for j in range(m):
				if a[i][j] != a[i][0]:
					ans[i] = j + 1
					break
			break
	if not flag:
		print('NIE')
	else:
		print('TAK')
		print(*ans)


from collections import Counter
(n, m) = map(int, input().split())
arr = []
for _ in range(n):
	arr.append(list(map(int, input().split())))
res = ['1'] * n
acc = 0
for i in range(n):
	acc ^= arr[i][0]
if acc > 0:
	print('TAK')
	print(' '.join(res))
else:
	i = 0
	while i < n and len(Counter(arr[i])) == 1:
		i += 1
	if i == n:
		print('NIE')
	else:
		j = 0
		while arr[i][j] == arr[i][0]:
			j += 1
		res[i] = str(j + 1)
		print('TAK')
		print(' '.join(res))


import sys
import os
from io import BytesIO, IOBase

def cel(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return defaultdict(int)

def ddl():
	return defaultdict(list)

def ddd():
	return defaultdict(defaultdict(int))
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 collections import defaultdict
for _ in range(1):
	(n, m) = mi()
	a = [li() for i in range(n)]
	res = [1 for i in range(n)]
	x = 0
	for i in range(n):
		x ^= a[i][0]
	if x > 0:
		print('TAK')
		print(*res)
	else:
		f = 0
		for i in range(n):
			for j in range(m):
				if a[i][j] != a[i][0]:
					res[i] = j + 1
					f = 1
					break
			if f == 1:
				break
		if f == 0:
			print('NIE')
		else:
			print('TAK')
			print(*res)


import sys
(n, m) = list(map(int, input().split()))
table = []
xor_test = 0
for _ in range(n):
	temp = list(map(int, input().split()))
	table.append(temp)
	xor_test ^= temp[0]
if xor_test != 0:
	print('TAK')
	for _ in range(len(table)):
		print(1, end=' ')
	sys.exit()
result_r = -1
result_c = -1
for i in range(len(table)):
	test = table[i][0]
	for j in range(1, len(table[i])):
		if table[i][j] != test:
			result_r = i
			result_c = j
			break
	if result_c != -1:
		break
if result_c == -1:
	print('NIE')
	sys.exit()
print('TAK')
for _ in range(result_r):
	print(1, end=' ')
print(result_c + 1, end=' ')
for _ in range(result_r + 1, len(table)):
	print(1, end=' ')


import functools

def solve():
	(row, col) = [int(i) for i in str.split(input(), ' ')]
	m = []
	for i in range(row):
		m.append(list(map(int, str.split(input(), ' '))))
	total = functools.reduce(lambda x, y: x ^ y, list(map(lambda x: x[0], m)))
	if total == 0:
		for i in range(row):
			for j in range(1, col):
				if m[i][j] != m[i][0]:
					print('TAK\n' + ' '.join(['1'] * i + [str(j + 1)] + ['1'] * (row - i - 1)))
					return
		print('NIE')
	else:
		print('TAK\n' + ' '.join(['1'] * row))
solve()


def check(M, n, m):
	A = []
	xxor = 0
	for i in range(n):
		xxor ^= M[i][0]
		A.append(1)
	if xxor != 0:
		print('TAK')
		print(*A)
		return
	for i in range(n):
		for j in range(1, m):
			if M[i][j] != M[i][0]:
				A[i] = j + 1
				print('TAK')
				print(*A)
				return
	print('NIE')
(n, m) = map(int, input().split())
M = []
for i in range(n):
	a = list(map(int, input().split()))
	M.append(a)
check(M, n, m)


(m, n) = map(int, input().split())

def get_unique(array):
	unique_array = []
	for value in array:
		if value not in unique_array:
			unique_array.append(value)
	return unique_array
matrix = []
ori_matrix = []
matrix_idx_controller = [0] * m
multiple_n_idx = set()
ans = 0
for i in range(m):
	j = list(map(int, input().split()))
	j_copy = list(j).copy()
	ori_matrix.append(j_copy)
	j = get_unique(j)
	matrix.append(j)
	if len(j) > 1:
		multiple_n_idx.add(i)
	ans ^= j[0]
try:
	while ans == 0:
		idx = multiple_n_idx.pop()
		matrix_idx_controller[idx] += 1
		controller = matrix_idx_controller[idx]
		ans ^= matrix[idx][controller - 1]
		ans ^= matrix[idx][controller]
	print('TAK')
	answer = []
	for (idx, ans) in enumerate(matrix_idx_controller):
		answer.append(str(ori_matrix[idx].index(matrix[idx][matrix_idx_controller[idx]]) + 1))
	answer = ' '.join(answer)
	print(answer)
except KeyError:
	print('NIE')


(n, m) = map(int, input().split())
b = []
a = []
xor = 0
for i in range(n):
	l = list(map(int, input().split()))
	xor ^= l[0]
	a.append(len(set(l)))
	b.append(l)
if xor != 0:
	print('TAK')
	ans = [1] * n
	print(*ans)
else:
	ans = [1] * n
	flag = 0
	for i in range(len(a)):
		if a[i] > 1:
			flag = 1
			for j in range(m):
				if b[i][j] != b[i][0]:
					ans[i] = j + 1
					break
			break
	if flag == 0:
		print('NIE')
	else:
		print('TAK')
		print(*ans)


(n, m) = map(int, input().split())
tab = []
for i in range(n):
	a = map(int, input().split())
	tab.append(list(a))
k = -1
for i in range(n):
	s = set()
	for j in range(m):
		s.add(tab[i][j])
	if len(s) > 1:
		k = i
		break
res = [1] * n
t = 0
for i in range(n):
	if i != k:
		t = t ^ tab[i][0]
if k == -1:
	if t == 0:
		print('NIE')
	else:
		print('TAK')
		print(*res)
else:
	for i in range(m):
		if t ^ tab[k][i] != 0:
			res[k] = i + 1
			print('TAK')
			print(*res)
			break
	else:
		print('NIE')


(sizeI, sizeJ) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(sizeI)]
ret = [0] * sizeI
xor = 0
for i in range(sizeI):
	xor ^= a[i][0]
for i in range(sizeI):
	if xor > 0:
		break
	for j in range(sizeJ):
		if xor ^ a[i][0] ^ a[i][j] > 0:
			ret[i] = j
			xor ^= a[i][0] ^ a[i][j]
			break
if xor == 0:
	print('NIE')
else:
	print('TAK')
	print(*map(lambda x: x + 1, ret))


(n, m) = map(int, input().split())
l = []
for i in range(n):
	x = list(map(int, input().split()))
	l.append(x)
xor = 0
a = []
for i in range(n):
	xor ^= l[i][0]
	a.append(1)
if xor == 0:
	for i in range(n):
		x = l[i][0]
		flag = 0
		for j in range(m):
			if l[i][j] != x:
				a[i] = j + 1
				print('TAK')
				print(' '.join(map(str, a)))
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('NIE')
else:
	print('TAK')
	print(' '.join(map(str, a)))


(n, m) = map(int, input().split())
list1 = []
for i in range(n):
	temp = list(map(int, input().split()))
	list1.append(temp)
temp = 0
ans = [1 for i in range(n)]
for i in range(n):
	temp = temp ^ list1[i][0]
if temp > 0:
	print('TAK')
	print(*ans)
else:
	f = 0
	for i in range(n):
		for j in range(1, m):
			if list1[i][j] != list1[i][0]:
				ans[i] = j + 1
				f = 1
				break
		if f == 1:
			break
	if f == 0:
		print('NIE')
	else:
		print('TAK')
		print(*ans)


import sys
(n, m) = map(int, input().split())
M = [[int(el) for el in input().split()] for _ in range(n)]
res = 0
for i in range(n):
	res ^= M[i][0]
if res:
	print('TAK')
	print(*[1 for _ in range(n)])
else:
	res = [1] * n
	for i in range(n):
		for j in range(m):
			if M[i][j] != M[i][0]:
				res[i] = j + 1
				print('TAK')
				print(*res)
				sys.exit(0)
	print('NIE')


(n, m) = [int(x) for x in input().split()]
answer = []
xor = 0
total = []
for i in range(n):
	a = [int(x) for x in input().split()]
	answer.append(a)
for item in answer:
	xor ^= item[0]
	total.append(1)
if xor > 0:
	print('TAK')
	print(*total)
else:
	for i in range(n):
		for j in range(m):
			if answer[i][j] != answer[i][0]:
				total[i] = j + 1
				print('TAK')
				print(*total)
				exit()
	print('NIE')


(r, c) = list(map(int, input().split()))
arr = []
for i in range(r):
	lista = list(map(int, input().split()))
	arr.append(lista)
a = 0
ans = [1 for i in range(r)]
for i in range(r):
	a = a ^ arr[i][0]
flag = 0
if a > 0:
	print('TAK')
	print(*ans)
elif a == 0:
	for i in range(r):
		for j in range(1, c):
			if arr[i][0] != arr[i][j]:
				flag = 1
				ans[i] = j + 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('NIE')
	else:
		print('TAK')
		print(*ans)


(n, m) = (int(x) for x in input().split())
matrix = [[int(x) for x in input().split()] for _ in range(n)]
my_xor = 0
ans = [1 for _ in range(n)]
for i in range(n):
	my_xor ^= matrix[i][0]
if my_xor > 0:
	print('TAK')
	print(*ans)
	quit()
for i in range(n):
	s = set(matrix[i])
	if len(s) > 1:
		my_xor ^= matrix[i][0]
	s.remove(matrix[i][0])
	for j in range(1, m):
		if matrix[i][j] in s:
			s.remove(matrix[i][j])
			my_xor ^= matrix[i][j]
			if my_xor > 0:
				ans[i] = j + 1
				print('TAK')
				print(*ans)
				quit()
			my_xor ^= matrix[i][j]
print('NIE')


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, M) = getInts()
	grid = []
	flag = False
	for n in range(N):
		grid.append(getInts())
		if not flag and len(set(grid[n])) > 1:
			flag = True
			idx = n
	if not flag:
		curr = 0
		for n in range(N):
			curr ^= grid[n][0]
		if curr:
			print('TAK')
			ans = [1] * N
			print(*ans)
			return
		print('NIE')
		return
	curr = 0
	for n in range(N):
		if n != idx:
			curr ^= grid[n][0]
	for m in range(M):
		if curr ^ grid[idx][m] > 0:
			break
	ans = [1] * idx + [m + 1] + [1] * (N - idx - 1)
	print('TAK')
	print(*ans)
	return
solve()


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

def f():
	global j, n
	r = 0
	for i in range(n):
		r ^= a[i][j[i]]
	return r
(n, m) = mp()
a = [list(mp()) for i in range(n)]
j = [0] * n
if f() == 0:
	for i in range(n):
		ac = 0
		for q in range(m):
			if a[i][q] != a[i][0]:
				j[i] = q
				ac = 1
				break
		if ac:
			break
if f() == 0:
	print('NIE')
else:
	print('TAK')
	print(' '.join([str(i + 1) for i in j]))


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

def cino(test=False):
	if not test:
		return int(input())
	else:
		return input()

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

def ssplit():
	return list(input().split())

def printlist(l):
	for i in l:
		print(i, end=' ')

def main():
	(n, m) = cin()
	l = []
	for _ in range(n):
		l1 = cina()
		l.append(l1)
	ans = 0
	for i in range(n):
		ans = ans ^ l[i][0]
	z = [1] * n
	if ans > 0:
		print('TAK')
		printlist(z)
	else:
		for i in range(n):
			for j in range(1, m):
				if l[i][0] != l[i][j]:
					z[i] = j + 1
					print('TAK')
					printlist(z)
					return
		print('NIE')
main()


import copy
(n, m) = map(int, input().strip().split())
matrix = [0] * n
no_pos = 1
for i in range(n):
	matrix[i] = list(map(int, input().strip().split()))
	sorted_mat = sorted(matrix[i])
	if any(matrix[i]) > 0:
		no_pos = 0
if no_pos == 1:
	print('NIE')
	exit(0)

def incr_sol(sol, n, m):
	new_sol = copy.deepcopy(sol)
	for i in range(n):
		if len(set(matrix[i])) > 1:
			cur = matrix[i][new_sol[i]]
			for (index, element) in enumerate(matrix[i]):
				if element == cur:
					continue
				else:
					new_sol[i] = index
					return new_sol
	return -1
while 1:
	sol = [0] * n
	result = 0
	for i in range(n):
		result ^= matrix[i][sol[i]]
	if result == 0:
		sol = incr_sol(sol, n, m)
		if sol == -1:
			print('NIE')
			exit(0)
	print('TAK')
	one_index = map(lambda x: x + 1, sol)
	print(' '.join(map(str, one_index)))
	exit(0)
	print('NIE')
	exit(0)


import sys
from math import gcd
import bisect
import heapq
from collections import deque
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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')
INF = 10 ** 18
MOD = 998244353
flag = False
(n, m) = Ri()
arr = []
for i in range(n):
	temp = Ri()
	arr.append(temp)
ts = set()
ind = -1
for i in range(n):
	s = set()
	for j in range(m):
		s.add(arr[i][j])
	if len(s) > 1:
		ind = i
		ts = s
		flag = True
		break
xor = 0
val = -1
for i in range(n):
	if i == ind:
		val = arr[i][0]
	xor = xor ^ arr[i][0]
if xor == 0:
	if not flag:
		print('NIE')
	else:
		print('TAK')
		for i in range(n):
			if ind == i:
				for j in range(m):
					if arr[i][j] != arr[i][0]:
						print(j + 1, end=' ')
						break
			else:
				print(1, end=' ')
else:
	print('TAK')
	print(*[1] * n)


(n, m) = map(int, input().split())
l = []
xor = 0
for i in range(n):
	l1 = list(map(int, input().split()))
	l.append(l1)
	if i == 0:
		xor = l1[0]
	else:
		xor = xor ^ l1[0]
if xor != 0:
	print('TAK')
	print('1 ' * n)
else:
	l1 = [1] * n
	f = False
	for i in range(n):
		for j in range(m):
			if l[i][j] != l[i][0]:
				l1[i] = j + 1
				f = True
				break
		if f:
			break
	if f:
		print('TAK')
		print(*l1)
	else:
		print('NIE')


(N, M) = map(int, input().split())
X = [[int(a) for a in input().split()] for i in range(N)]
(i0, j0) = (-1, -1)
for i in range(N):
	for j in range(M - 1):
		if X[i][j] != X[i][j + 1]:
			(i0, j0) = (i, j + 1)
			break
	if i0 >= 0:
		break
s = 0
for i in range(N):
	s ^= X[i][0]
if s > 0:
	print('TAK')
	print(*[1] * N)
elif i0 >= 0:
	print('TAK')
	print(*[1] * i0 + [j0 + 1] + [1] * (N - i0 - 1))
else:
	print('NIE')


(n, m) = [int(i) for i in input().split()]
a = []
for i in range(n):
	a.append([int(j) for j in input().split()])
arr = []
xor = 0
for i in range(n):
	xor ^= a[i][0]
	arr.append(1)
if xor:
	print('TAK')
	print(*arr)
else:
	flag = 0
	for i in range(n):
		val = xor
		val ^= a[i][0]
		for j in range(1, m):
			if val ^ a[i][j] > 0:
				flag = 1
				arr[i] = j + 1
				break
		if flag:
			break
	if flag:
		print('TAK')
		print(*arr)
	else:
		print('NIE')


def main():
	(n, m) = list(map(int, input().split(' ')))
	num = []
	for i in range(n):
		num.append(list(map(int, input().split(' '))))
	ans = 0
	for i in range(n):
		ans ^= num[i][0]
	if ans != 0:
		print('TAK')
		for i in range(n):
			print(1, end=' ')
		print('\n')
		return
	else:
		for i in range(n):
			for j in range(m):
				if num[i][j] != num[i][0]:
					print('TAK')
					for k in range(n):
						if k != i:
							print(1, end=' ')
						else:
							print(j + 1, end=' ')
					print('\n')
					return
	print('NIE\n')
main()


def matrixNdxor(n, m):
	matrix = []
	firstXor = 0
	for i in range(n):
		row = []
		values = input()
		values = values.split()
		for j in range(m):
			row.append(int(values[j]))
		matrix.append(row)
		firstXor ^= int(values[0])
	return [matrix, firstXor]

def finder(n, m, matrix, firstXor):
	ans = ''
	for i in range(n):
		for j in range(1, m):
			if matrix[i][j] != matrix[i][0]:
				for a in range(n):
					if a == i:
						ans += str(j + 1) + ' '
					else:
						ans += '1 '
				return ans
	return False
values = input()
(n, m) = values.split()
n = int(n)
m = int(m)
(matrix, firstXor) = matrixNdxor(n, m)
if firstXor > 0:
	print('TAK')
	ans = ''
	for i in range(n):
		ans += '1 '
	print(ans)
else:
	res = finder(n, m, matrix, firstXor)
	if res != False:
		print('TAK')
		print(res)
	else:
		print('NIE')


(n, m) = map(int, input().split())
arr = []
ans = 0
for i in range(n):
	k = list(map(int, input().split()))
	ans ^= k[0]
	arr.append(k)
ind = [0] * n
if ans == 0:
	for i in range(n):
		for j in range(1, m):
			ans ^= arr[i][0]
			ans ^= arr[i][j]
			if ans:
				ind[i] = j
				break
			else:
				ans ^= arr[i][j]
				ans ^= arr[i][0]
		if ind[i] != 0:
			break
if ans:
	print('TAK')
	for i in range(n):
		print(ind[i] + 1, end=' ')
else:
	print('NIE')


(n, m) = map(int, input().split())
x = 0
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
	x ^= l[i][0]
if x != 0:
	print('TAK')
	print('1 ' * n)
else:
	t = False
	ans = [1] * n
	for i in range(n):
		for j in range(m):
			if x ^ l[i][0] ^ l[i][j] != 0:
				print('TAK')
				ans[i] = j + 1
				print(*ans)
				t = True
				break
		if t:
			break
	else:
		print('NIE')


(n, m) = map(int, input().split())
dp = [[int(i) for i in input().split()] for j in range(n)]
res = 0
for i in range(n):
	res ^= dp[i][0]
if res:
	print('TAK')
	print(*[1] * n)
else:
	resa = [1] * n
	for i in range(n):
		for j in range(m):
			if dp[i][0] != dp[i][j]:
				resa[i] = j + 1
				print('TAK')
				print(*resa)
				exit()
	print('NIE')


(n, m) = map(int, input().split())
mat = []
for i in range(n):
	l = [int(i) for i in input().split()]
	mat.append(l)
ans = []
xor = 0
for i in mat:
	xor ^= i[0]
	ans.append(1)
if xor:
	print('TAK')
	print(*ans)
	exit()
else:
	for i in range(n):
		for j in range(m):
			if mat[i][j] ^ mat[i][0] > 0:
				ans[i] = j + 1
				print('TAK')
				print(*ans)
				exit()
print('NIE')


(n, m) = [int(i) for i in input().split()]
ls = []
for i in range(n):
	ls.append([int(i) for i in input().split()])
ans = 0
for i in range(n):
	ans ^= ls[i][0]
res = []
if ans != 0:
	res = [1 for i in range(n)]
else:
	for i in range(n):
		for j in range(m):
			if ls[i][0] != ls[i][j]:
				res += [1 for k in range(i)]
				res.append(j + 1)
				res += [1 for k in range(i + 1, n)]
				break
		if len(res) > 0:
			break
if len(res) == 0:
	print('NIE')
else:
	print('TAK')
	for i in res:
		print(i, end=' ')
	print('')


(n, m) = list(map(int, input().split()))
matrix = []
for _ in range(n):
	matrix.append(list(map(int, input().split())))
init_xor = 0
for i in range(n):
	init_xor ^= matrix[i][0]
ok = False
if init_xor > 0:
	print('TAK')
	print(*[1 for i in range(n)])
	ok = True
else:
	for i in range(n):
		if ok:
			break
		for j in range(1, m):
			if matrix[i][j] != matrix[i][0]:
				ans = [1 for i in range(n)]
				ans[i] = j + 1
				print('TAK')
				print(*ans)
				ok = True
				break
if not ok:
	print('NIE')


def solve():
	(N, M) = map(int, input().split())
	matrix = []
	ans = 0
	result = [1] * N
	for _ in range(N):
		matrix.append([int(k) for k in input().split()])
		ans ^= matrix[-1][0]
	col = 0
	while col < N and (not ans):
		for i in range(1, M):
			ans ^= matrix[col][i - 1]
			ans ^= matrix[col][i]
			if ans > 0:
				result[col] = i + 1
				break
		col += 1
	if ans == 0:
		print('NIE')
		return
	print('TAK')
	print(' '.join((str(k) for k in result)))
solve()


l = input().split()
n = int(l[0])
m = int(l[1])
lfi = []
for i in range(n):
	l = input().split()
	li = [int(i) for i in l]
	lfi.append(li)
xori = 0
for i in range(n):
	xori = xori ^ lfi[i][0]
if xori != 0:
	print('TAK')
	for i in range(n):
		print(1, end=' ')
	print()
	quit()
done = 0
arr = [1 for i in range(n)]
for i in range(n):
	for j in range(m):
		if lfi[i][j] != lfi[i][0]:
			done = 1
			arr[i] = j + 1
			break
	if done:
		break
if done:
	print('TAK')
	for i in range(n):
		print(arr[i], end=' ')
	quit()
print('NIE')