#include <bits/stdc++.h>
using namespace std;
const int N = 200023;
set<long long int> s;
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int a[n][m];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  long long int currxor = a[0][0];
  for (long long int i = 1; i < n; i++) currxor ^= a[i][0];
  if (currxor != 0) {
    cout << "TAK" << endl;
    for (long long int i = 0; i < n; i++)
      cout << "1"
           << " ";
    return;
  } else {
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 1; j < m; j++) {
        if (a[i][0] != a[i][j]) {
          cout << "TAK" << endl;
          for (long long int k = 0; k < n; k++) {
            if (k == i)
              cout << j + 1 << " ";
            else
              cout << "1"
                   << " ";
          }
          return;
        }
      }
    }
  }
  cout << "NIE";
}
int main() {
  long long int T;
  T = 1;
  long long int t = 0;
  while ((t++) < T) {
    solve();
    cout << endl;
  }
  return 0;
}
