#include <bits/stdc++.h>
using namespace std;
int n, m;
int dp[1025][505];
int dizi[505][505] = {0};
int dpf(int cor, int str, vector<int> v) {
  int muttin;
  if (str == (n - 1)) {
    if (cor) {
      printf("TAK\n");
      for (int i = 0; i < v.size(); i++) {
        printf("%d ", v[i] + 1);
      }
      exit(0);
    }
    return 0;
  }
  if (dp[cor][str] != -1) {
    return dp[cor][str];
  }
  for (int i = 0; i < m; i++) {
    v.push_back(i);
    muttin = dpf((cor xor dizi[str + 1][i]), str + 1, v);
    if (muttin != 0) {
      dp[cor][str] = 1;
    } else if (dp[cor][str] == -1) {
      dp[cor][str] = 0;
    }
    v.pop_back();
  }
  return dp[cor][str];
}
vector<int> a;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &dizi[i][j]);
    }
  }
  for (int i = 0; i < 1025; i++) {
    for (int j = 0; j < 505; j++) {
      dp[i][j] = -1;
    }
  }
  for (int i = 0; i < m; i++) {
    a.push_back(i);
    dpf(dizi[0][i], 0, a);
    a.pop_back();
  }
  printf("NIE\n");
}
