#include <bits/stdc++.h>
using namespace std;
const long long prime = 1000000007;
const long long maxN = 1e6 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, a[505][505], ci = 0, cj = 0, ans = 0, anstemp;
  cin >> n >> m;
  for (long long i = (long long)(1); i <= (long long)(n); i++) {
    for (long long j = (long long)(1); j <= (long long)(m); j++) {
      cin >> a[i][j];
    }
    ans ^= a[i][1];
  }
  for (long long i = (long long)(1); i <= (long long)(n); i++) {
    for (long long j = (long long)(1); j <= (long long)(m); j++) {
      anstemp = ans ^ a[i][1] ^ a[i][j];
      if (anstemp > 0) {
        ci = i;
        cj = j;
        break;
      }
    }
  }
  if (ci == 0 && cj == 0) {
    cout << "NIE";
    return 0;
  } else {
    cout << "TAK" << endl;
  }
  for (long long i = (long long)(1); i <= (long long)(n); i++) {
    if (i != ci) {
      cout << 1 << " ";
    } else {
      cout << cj << " ";
    }
  }
  return 0;
}
