#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
long long power(long long a, long long b);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long a[n + 1][m + 1];
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= m; j++) cin >> a[i][j];
    }
    vector<long long> ans;
    long long val = 0;
    for (long long i = 1; i <= n; i++) {
      ans.push_back(1);
      val = val ^ a[i][1];
    }
    if (val > 0) {
      cout << "TAK"
           << "\n";
      for (auto x : ans) cout << x << " ";
      cout << "\n";
      return 0;
    }
    for (long long i = 1; i <= n; i++) {
      for (long long j = 2; j <= m; j++) {
        if (a[i][j] != a[i][j - 1]) {
          val = val ^ a[i][j - 1];
          val = val ^ a[i][j];
          ans[i - 1] = j;
          if (val > 0) {
            cout << "TAK"
                 << "\n";
            for (auto x : ans) cout << x << " ";
            cout << "\n";
            return 0;
          }
        }
      }
    }
    cout << "NIE"
         << "\n";
  }
  return 0;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2)
      b--, res = res * a;
    else
      b = b / 2, a *= a;
  }
  return res;
}
