#include <bits/stdc++.h>
using namespace std;
const int maxn = 500 + 10;
const int inf = 0x3f3f3f3f;
set<int> se[maxn];
map<int, int> mp;
int ans[maxn];
int g[maxn][maxn];
int main() {
  int n, m;
  cin >> n >> m;
  int flag = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &g[i][j]);
  int tip = 0;
  for (int i = 0; i < n; i++) {
    ans[i] = 1;
    tip ^= g[i][0];
  }
  if (tip != 0) {
    cout << "TAK" << endl;
    for (int i = 0; i < n; i++) {
      if (i) printf(" ");
      printf("%d", ans[i]);
    }
    return 0;
  } else {
    int flag = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (g[i][j] != g[i][0]) {
          flag = 1;
          ans[i] = j + 1;
          break;
        }
      }
      if (flag) break;
    }
    if (flag == 0)
      cout << "NIE" << endl;
    else {
      cout << "TAK" << endl;
      for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        printf("%d", ans[i]);
      }
    }
  }
  return 0;
}
