#include <bits/stdc++.h>
using namespace std;
const int maxn = 505;
int ans[maxn];
int a[maxn][maxn];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int fg = 0;
  int rec = a[1][1];
  for (int i = 1; i <= n; i++) ans[i] = 1;
  for (int i = 2; i <= n; i++) rec ^= a[i][1];
  if (rec) fg = 1;
  if (!fg) {
    for (int i = 1; i <= n; i++) {
      for (int j = 2; j <= m; j++) {
        if (a[i][j] != a[i][j - 1]) {
          fg = 1;
          ans[i] = j;
          i = n + 1;
          break;
        }
      }
    }
  }
  if (fg) {
    cout << "TAK" << endl;
    for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  } else
    cout << "NIE" << endl;
}
