#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline int read();
const int M = 500016, MOD = 1000000007;
int save[512][512];
int main(void) {
  int n = read(), m = read();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) save[i][j] = read();
  int x = 0;
  for (int i = 1; i <= n; ++i) x ^= save[i][1];
  if (x) {
    printf("TAK\n");
    for (int i = 1; i <= n; ++i) printf("%d ", 1);
    return 0;
  }
  int tr = -1, tc = -1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (save[i][j] != save[i][1]) {
        tr = i, tc = j;
        i = n + 1;
      }
    }
  }
  if (tr == -1) {
    printf("NIE\n");
    return 0;
  }
  printf("TAK\n");
  for (int i = 1; i <= n; ++i) printf("%d ", i == tr ? tc : 1);
  return 0;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
