#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[505][505], b[505][505];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      b[i][j] = a[i][j];
    }
  }
  int diferentes = 0, L, expo;
  for (int k = 0; k < 10 && diferentes == 0; k++) {
    for (int i = 0; i < n; i++) {
      int linha = a[i][0] % 2;
      for (int j = 0; j < m; j++) {
        if (a[i][j] % 2 != linha) {
          diferentes = j;
          L = i;
        }
      }
    }
    if (diferentes == 0) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) a[i][j] /= 2;
      }
    }
  }
  if (diferentes == 0) {
    int XOR = b[0][0];
    for (int i = 1; i < n; i++) {
      XOR = XOR ^ b[i][0];
    }
    if (XOR == 0)
      cout << "NIE" << endl;
    else {
      cout << "TAK\n";
      for (int i = 0; i < n; i++) cout << 1 << " ";
    }
  } else {
    cout << "TAK" << endl;
    int uns = 0;
    for (int i = 0; i < n; i++)
      if (a[i][0] % 2 == 1) uns++;
    if (uns % 2 == 1) {
      for (int i = 0; i < n; i++) cout << 1 << " ";
    } else {
      for (int i = 0; i < L; i++) cout << 1 << " ";
      cout << diferentes + 1 << " ";
      for (int i = L + 1; i < n; i++) cout << 1 << " ";
    }
  }
  return 0;
}
