#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > v(n, vector<int>(m));
  for (int i = (0); i < int(n); i++) {
    for (int j = (0); j < int(m); j++) {
      cin >> v[i][j];
    }
  }
  vector<int> dif(n, -1);
  int g = -1;
  for (int i = (0); i < int(n); i++) {
    for (int j = (0); j < int(m); j++) {
      if (v[i][j] != v[i][0]) {
        dif[i] = j + 1;
        g = i;
        break;
      }
    }
  }
  int cur1 = 0;
  for (int i = (0); i < int(n); i++) cur1 ^= v[i][0];
  if (cur1) {
    cout << "TAK" << endl;
    for (int i = (0); i < int(n); i++) cout << 1 << ' ';
    cout << endl;
  } else if (g != -1) {
    cout << "TAK" << endl;
    for (int i = (0); i < int(n); i++) cout << (i == g ? dif[i] : 1) << ' ';
    cout << endl;
  } else
    cout << "NIE" << endl;
}
