#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int c[n][m];
  int tmp = 0;
  int ans[n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> c[i][j];
    }
    tmp ^= c[i][0];
    ans[i] = 0;
  }
  if (tmp == 0) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (c[i][j] != c[i][0]) {
          tmp ^= c[i][0] ^ c[i][j];
          ans[i] = j;
          break;
        }
      }
      if (tmp != 0) break;
    }
  }
  if (tmp == 0) {
    cout << "NIE\n";
  } else {
    cout << "TAK\n";
    for (int i = 0; i < n; i++) {
      if (i) cout << " ";
      cout << ans[i] + 1;
    }
    cout << "\n";
  }
  return 0;
}
