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