#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[505][505];
int dp[505][5];
pair<int, int> diff = make_pair(-1, -1);
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int prv = 0;
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      if (j == 0)
        prv = a[i][j];
      else if (a[i][j] != prv)
        diff = make_pair(i, j);
    }
  }
  int cur = 0;
  for (int i = 0; i < n; i++) {
    cur ^= a[i][0];
  }
  if (cur != 0) {
    printf("TAK\n");
    for (int i = 0; i < n; i++) {
      printf("1 ");
    }
    printf("\n");
  } else {
    if (diff == make_pair(-1, -1)) {
      printf("NIE\n");
    } else {
      printf("TAK\n");
      for (int i = 0; i < n; i++) {
        if (i == diff.first)
          printf("%d ", diff.second + 1);
        else
          printf("1 ");
      }
    }
  }
  return 0;
}
