#include <bits/stdc++.h>
using namespace std;
const int N = 500 + 5;
const long long inf = 1791791791;
const long long mod = 1e9 + 7;
int ma[N][N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> resp;
  int x = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &ma[i][j]);
    }
    x ^= ma[i][0];
    resp.push_back(1);
  }
  if (x == 0) {
    for (int i = 0; i < n; i++) {
      for (int j = 1; j < m; j++) {
        if (ma[i][j] != ma[i][0]) {
          x ^= (ma[i][j] ^ ma[i][0]);
          resp[i] = j + 1;
          break;
        }
      }
      if (x) break;
    }
  }
  if (x == 0) {
    printf("NIE\n");
    return 0;
  }
  printf("TAK\n");
  for (int i = 0; i < n; i++) {
    printf("%d%c", resp[i], " \n"[i == n - 1]);
  }
  return 0;
}
