#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y / 2, x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long arr[n][m];
  long long i, j, k;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> arr[i][j];
  long long zero[n];
  long long one[n];
  for (k = 0; k < 10; k++) {
    for (i = 0; i < n; i++) zero[i] = -1, one[i] = -1;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if ((arr[i][j] & (1 << k))) {
          one[i] = j;
        } else
          zero[i] = j;
      }
    }
    long long cnt1 = 0;
    for (i = 0; i < n; i++) {
      if (one[i] != -1) cnt1++;
    }
    if (cnt1 % 2) {
      cout << "TAK\n";
      for (i = 0; i < n; i++) {
        if (one[i] != -1)
          cout << one[i] + 1;
        else
          cout << zero[i] + 1;
        cout << " ";
      }
      return 0;
    } else {
      bool poss = false;
      for (i = 0; i < n; i++) {
        if (one[i] != -1 and zero[i] != -1) {
          one[i] = zero[i];
          poss = true;
          break;
        }
      }
      if (poss) {
        cout << "TAK\n";
        for (i = 0; i < n; i++) {
          if (one[i] != -1)
            cout << one[i] + 1;
          else
            cout << zero[i] + 1;
          cout << " ";
        }
        return 0;
      }
    }
  }
  cout << "NIE";
}
