#include <bits/stdc++.h>
using namespace std;
bool prime[1000005];
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void SieveOfEratosthenes() {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= 1000000; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= 1000000; i += p) prime[i] = false;
    }
  }
}
int main() {
  long long int n, m, i, j;
  cin >> n >> m;
  long long int a[n][m];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) cin >> a[i][j];
  }
  long long int temp = 0;
  for (i = 0; i < n; i++) {
    temp ^= a[i][0];
  }
  if (temp > 0) {
    cout << "TAK" << endl;
    for (i = 0; i < n; i++) cout << "1 ";
    cout << endl;
    return 0;
  }
  long long int row = -1, col = -1;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (a[i][j] != a[i][0]) {
        col = j;
        row = i;
        break;
      }
    }
  }
  if (row == -1) {
    cout << "NIE" << endl;
    return 0;
  }
  cout << "TAK" << endl;
  for (i = 0; i < n; i++) {
    if (i != row)
      cout << "1 ";
    else
      cout << col + 1 << " ";
  }
  cout << endl;
}
