#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, i, j, x = 0, l = -1;
  cin >> n >> m;
  int arr[n][m];
  int b[n], c[n];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> arr[i][j];
      if (j == 0) {
        b[i] = j + 1;
        c[i] = arr[i][0];
        x ^= arr[i][0];
      }
    }
  }
  if (x != 0) {
    cout << "TAK" << endl;
    for (i = 0; i < n; i++) {
      cout << b[i] << " ";
    }
    return 0;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (arr[i][j] != c[i] && ((x ^ c[i]) ^ arr[i][j]) > 0) {
        c[i] = arr[i][j];
        b[i] = j + 1;
        l = 0;
        break;
      }
    }
    if (l == 0) {
      break;
    }
  }
  if (l == -1) {
    cout << "NIE";
    return 0;
  } else {
    cout << "TAK" << endl;
    for (i = 0; i < n; i++) {
      cout << b[i] << " ";
    }
  }
  return 0;
}
