#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> m(N + 1, vector<int>(M + 1));
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= M; ++j) {
      cin >> m[i][j];
    }
  }
  int chosen_row_xor = 0;
  for (int i = 1; i <= N; ++i) {
    chosen_row_xor ^= m[i][1];
  }
  if (chosen_row_xor) {
    cout << "TAK" << endl;
    for (int i = 0; i < N; ++i) {
      cout << 1 << " ";
    }
    cout << endl;
    return 0;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 2; j <= M; ++j) {
      if (chosen_row_xor ^ m[i][1] ^ m[i][j]) {
        cout << "TAK" << endl;
        for (int r = 1; r <= N; ++r) {
          if (r == i) {
            cout << j << " ";
          } else {
            cout << 1 << " ";
          }
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << "NIE" << endl;
  return 0;
}
