#include <bits/stdc++.h>
using namespace std;
void KeepTrying() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> V(n, vector<int>(m));
  for (auto& v : V) {
    for (auto& x : v) cin >> x;
  }
  int X = 0;
  vector<int> ans(n, 1);
  for (auto& v : V) X ^= v.front();
  if (X == 0) {
    int idx = 0;
    for (auto& v : V) {
      for (int i = 0; i < m; i++) {
        if (v[i] != v.front()) {
          X = 1;
          ans[idx] = i + 1;
          break;
        }
      }
      if (X == 1) break;
      idx++;
    }
  }
  if (!X)
    puts("NIE");
  else {
    cout << "TAK\n";
    for (auto& ANS : ans) cout << ANS << ' ';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int DontGiveUp = 1;
  while (DontGiveUp--) KeepTrying();
  return 0;
}
