#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int a[n + 1][m + 1];
  set<long long int, greater<long long int> > g[n + 1];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      cin >> a[i][j];
      g[i].insert(a[i][j]);
    }
  }
  if (n == 1 || m == 1) {
    if (n == 1) {
      long long int ff = 0;
      for (long long int i = 0; i < m; i++) {
        if (a[0][i] != 0) {
          cout << "TAK\n";
          cout << i + 1;
          ff = 1;
          return 0;
        }
      }
      cout << "NIE\n";
      return 0;
    }
    if (m == 1) {
      long long int ans = a[0][0];
      for (long long int i = 0; i < n; i++) {
        if (i != 0) {
          ans ^= a[i][0];
        }
      }
      if (ans == 0) {
        cout << "NIE\n";
        return 0;
      } else {
        cout << "TAK\n";
        for (long long int i = 0; i < n; i++) {
          cout << 1 << " ";
        }
        return 0;
      }
    }
  }
  long long int pos, ss = 0;
  for (long long int i = 0; i < n; i++) {
    if (g[i].size() > 1) {
      pos = i;
      ss = 1;
      break;
    }
  }
  if (ss == 0) {
    long long int ans = a[0][0];
    for (long long int i = 0; i < n; i++) {
      if (i != 0) {
        ans ^= a[i][0];
      }
    }
    if (ans == 0) {
      cout << "NIE\n";
      return 0;
    } else {
      cout << "TAK\n";
      for (long long int i = 0; i < n; i++) {
        cout << 1 << " ";
      }
      return 0;
    }
  }
  long long int rr = 0, ans;
  for (long long int i = 0; i < n; i++) {
    if (i != pos) {
      if (rr == 0) {
        ans = a[i][0];
        rr = 1;
      } else {
        ans ^= a[i][0];
      }
    }
  }
  long long int pos2;
  for (long long int i = 0; i < m; i++) {
    if ((ans ^ a[pos][i]) != 0) {
      pos2 = i;
      break;
    }
  }
  cout << "TAK\n";
  for (long long int i = 0; i < n; i++) {
    if (i == pos) {
      cout << pos2 + 1 << " ";
    } else {
      cout << 1 << " ";
    }
  }
}
