#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, inf = 1e18 + 100;
long long a[505][505];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, x = 0;
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= m; ++j) cin >> a[i][j];
    x ^= (a[i][1]);
  }
  if (x > 0) {
    cout << "TAK" << '\n';
    for (long long i = 1; i <= n; ++i) cout << 1 << ' ';
    return 0;
  }
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 2; j <= m; ++j) {
      if (a[i][j] != a[i][1]) {
        cout << "TAK" << '\n';
        for (long long l = 1; l < i; ++l) cout << 1 << ' ';
        cout << j << ' ';
        for (long long l = i + 1; l <= n; ++l) cout << 1 << ' ';
        return 0;
      }
    }
  }
  cout << "NIE";
  return 0;
}
