#include <bits/stdc++.h>
int gcd(int a, int b) {
  for (; a;) {
    int tmp = a;
    a = b % a, b = tmp;
  }
  return b;
}
using namespace std;
int a[505][505];
int c[505];
int main() {
  int n, m;
  cin >> n >> m;
  int val = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cin >> a[i][j];
    c[i] = 1;
    val ^= a[i][1];
  }
  for (int i = 1; i <= n && !val; i++) {
    int j = 2;
    for (; j <= m && !val; j++) {
      val ^= a[i][j - 1];
      val ^= a[i][j];
    }
    c[i] = j - 1;
  }
  if (val) {
    cout << "TAK\n";
    for (int i = 1; i <= n; i++) {
      cout << c[i] << ' ';
    }
    cout << '\n';
  } else {
    cout << "NIE\n";
  }
  return 0;
}
