#include <bits/stdc++.h>
using namespace std;
vector<int> peguei, posi;
int n, m;
int mat[503][503];
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mat[i][j];
    }
  }
  int xx = 0;
  for (int i = 0; i < n; i++) {
    posi.push_back(0);
    peguei.push_back(mat[i][0]);
    xx ^= mat[i][0];
  }
  if (xx == 0) {
    bool deu = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mat[i][j] != peguei[i]) {
          deu = true;
          posi[i] = j;
          break;
        }
      }
      if (deu) break;
    }
    if (!deu)
      cout << "NIE" << endl;
    else {
      cout << "TAK" << endl;
      for (int i = 0; i < n; i++) cout << posi[i] + 1 << " ";
      cout << endl;
      return 0;
    }
  } else {
    cout << "TAK" << endl;
    for (int i = 0; i < n; i++) cout << posi[i] + 1 << " ";
    cout << endl;
    return 0;
  }
  return 0;
}
