#include <bits/stdc++.h>
using namespace std;
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> arr[i][j];
  int xr = 0;
  for (int i = 0; i < n; i++) xr ^= arr[i][0];
  if (xr == 0) {
    for (int i = 0; i < n; i++) {
      set<int> st;
      for (int j = 0; j < m; j++) {
        st.insert(arr[i][j]);
      }
      if (st.size() > 1) {
        for (int j = 1; j <= m - 1; j++) {
          if (arr[i][j] != arr[i][0]) {
            cout << "TAK\n";
            i++;
            for (int k = 1; k <= i - 1; k++) cout << 1 << ' ';
            cout << j + 1 << ' ';
            for (int k = i + 1; k <= n; k++) cout << 1 << ' ';
            return 0;
          }
        }
      }
    }
    cout << "NIE";
  } else {
    cout << "TAK\n";
    for (int i = 0; i < n; i++) cout << 1 << ' ';
  }
}
