#include <bits/stdc++.h>
using namespace std;
unsigned short table[500][500];
unsigned short sol[500];
int main() {
  long long t;
  long long a, b;
  cin >> a >> b;
  set<int> ss;
  for (long long i = 0; i < a; ++i) {
    for (long long j = 0; j < b; ++j) {
      int temp;
      cin >> temp;
      table[i][j] = temp;
    }
  }
  bool found = false;
  unsigned short xr_orig = 0;
  unsigned short xr = 0;
  for (long long i = 0; i < a; ++i) {
    xr_orig = xr_orig ^ table[i][0];
    sol[i] = 0;
  }
  xr = xr_orig;
  for (long long i = 0; i < a; ++i) {
    if (xr) {
      found = true;
      break;
    }
    unsigned short xr2 = xr_orig ^ table[i][0];
    for (long long j = 1; j < b; ++j) {
      unsigned short xr3 = xr2 ^ table[i][j];
      sol[i] = j;
      if (xr3) {
        found = true;
        break;
      }
    }
    if (!found) {
      sol[i] = 0;
    } else {
      break;
    };
  }
  if (found) {
    cout << "TAK" << endl;
    for (long long i = 0; i < a; ++i) {
      cout << sol[i] + 1 << " ";
    }
  } else {
    cout << "NIE" << endl;
  }
  return 0;
}
