#include <bits/stdc++.h>
using namespace std;
int n, m;
int mapa[502][502];
int sol[502];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> mapa[i][j];
  int res = 0;
  bool posible = false;
  for (int i = 1; i <= n; i++) {
    res = (res ^ mapa[i][1]);
    sol[i] = 1;
  }
  if (res == 0) {
    for (int i = 1; i <= n && !posible; i++) {
      for (int j = 2; j <= m && !posible; j++) {
        if (mapa[i][j] != mapa[i][1]) {
          posible = true;
          sol[i] = j;
        }
      }
    }
  } else {
    posible = true;
  }
  if (posible) {
    cout << "TAK\n";
    for (int i = 1; i <= n; i++) cout << sol[i] << " ";
    cout << "\n";
  } else {
    cout << "NIE\n";
  }
  return 0;
}
