#include <bits/stdc++.h>
using namespace std;
void test(int a, int b, int c, int d) {
  printf("%d %d %d %d", a, b, c, d);
  printf("\n");
}
void test(int a, int b, int c) {
  printf("%d %d %d ", a, b, c);
  printf("\n");
}
void test(int a, int b) {
  printf("%d %d ", a, b);
  printf("\n");
}
void test(char a, char b, char c, char d) {
  printf("%c %c %c %c", a, b, c, d);
  printf("\n");
}
int main() {
  int t = 1;
  while (t--) {
    int n, m;
    scanf("%d%d", &n, &m);
    int a[n][m];
    int sr = -1, f = 1;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i][0]);
      for (int j = 1; j < m; j++) {
        scanf("%d", &a[i][j]);
        if (f) {
          if (a[i][j] != a[i][j - 1]) {
            f = 0;
            sr = i;
          }
        }
      }
      if (i != sr) ans = ans ^ a[i][0];
    }
    if (sr == -1) {
      if (ans == 0)
        printf("NIE\n");
      else {
        printf("TAK\n");
        for (int i = 0; i < n; i++) {
          printf("%d", 1);
          printf(" ");
        }
      }
    } else {
      printf("TAK\n");
      for (int j = 0; j < n; j++) {
        if (j != sr) {
          printf("%d", 1);
          printf(" ");
        } else {
          for (int i = 0; i < m; i++) {
            if (a[sr][i] != ans) {
              printf("%d", i + 1);
              printf(" ");
              break;
            }
          }
        }
      }
    }
  }
}
