#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  int arr[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  int xo = 0;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    ans.push_back(1);
    xo = xo ^ arr[i][0];
  }
  bool done = false;
  if (xo > 0) {
    cout << "TAK\n";
    for (int i = 0; i < n; i++) {
      cout << "1 ";
    }
    return;
  } else {
    for (int i = 0; i < n; i++) {
      for (int j = 1; j < m; j++) {
        if (arr[i][j] != arr[i][j - 1]) {
          done = true;
          ans[i] = j + 1;
          break;
        }
      }
      if (done) break;
    }
  }
  if (done) {
    cout << "TAK\n";
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
  } else {
    cout << "NIE";
  }
}
int main() { solve(); }
