#include <bits/stdc++.h>
using namespace std;
long long modularExponentiation(long long x, long long n,
                                long long M = 1000000007) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return modularExponentiation((x * x) % M, n / 2, M);
  else
    return (x * modularExponentiation((x * x) % M, (n - 1) / 2, M)) % M;
}
long long abs(long long a, long long b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}
void solve();
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  long long a[n][m];
  vector<long long> v(n, 0);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] != a[i][0]) v[i] = j;
    }
  }
  long long ans = a[0][0];
  vector<long long> c(n, 0);
  for (long long i = 1; i < n; i++) {
    ans ^= a[i][0];
  }
  if (ans == 0) {
    for (long long i = 0; i < n; i++) {
      if (v[i]) {
        ans ^= v[i];
        c[i] = v[i];
        break;
      }
    }
    if (!ans) {
      cout << "NIE"
           << "\n";
      return;
    }
  }
  cout << "TAK"
       << "\n";
  for (long long i = 0; i < n; i++) cout << c[i] + 1 << " ";
  cout << "\n";
}
