#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  long long int arr[n][m];
  for (long long int i = 0; i < n; i++)
    for (long long int j = 0; j < m; j++) cin >> arr[i][j];
  vector<long long int> ans(n, 0);
  long long int x = 0;
  for (long long int i = 0; i < n; i++) x ^= arr[i][0];
  bool done = true;
  if (x == 0) {
    done = false;
    for (long long int i = 0; i < n && !done; i++) {
      for (long long int j = 1; j < m; j++) {
        if (arr[i][j] != arr[i][0]) {
          ans[i] = j;
          done = true;
          break;
        }
      }
    }
  }
  if (done) {
    cout << "TAK\n";
    for (long long int i = 0; i < n; i++) cout << ans[i] + 1 << " ";
  } else {
    cout << "NIE";
  }
}
