#include <bits/stdc++.h>
using namespace std;
long long mod = 1e17 + 3;
long long mod1 = 1e9 + 7;
const long long N = 3e5 + 10;
long long n, m;
long long a[503][503], x = 0;
void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  for (int i = 0; i < n; i++) x = x ^ a[i][0];
  if (x != 0) {
    cout << "TAK\n";
    for (int i = 0; i < n; i++) cout << "1 ";
    return;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < m; j++) {
      if (a[i][j] != a[i][0]) {
        cout << "TAK\n";
        for (int k = 0; k < n; k++)
          if (i == k)
            cout << j + 1 << " ";
          else
            cout << 1 << " ";
        return;
      }
    }
  }
  cout << "NIE";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
