#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, k, diff = 0;
  int xx, yy;
  cin >> n >> m;
  int a[n][m];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] != a[i][0] && diff == 0) {
        diff = 1;
        xx = i;
        yy = j;
      }
    }
  }
  int sum = 0;
  for (i = 0; i < n; i++) {
    sum = sum ^ a[i][0];
  }
  if (sum == 0 && diff == 0) {
    cout << "NIE";
  } else if (sum != 0) {
    cout << "TAK" << endl;
    for (i = 1; i <= n; i++) cout << 1 << " ";
  } else {
    cout << "TAK" << endl;
    ;
    for (i = 0; i < n; i++) {
      if (i != xx) {
        cout << 1 << " ";
      } else
        cout << yy + 1 << " ";
    }
  }
}
