#include <bits/stdc++.h>
using namespace std;
long long int mat[505][505];
void solve() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> ans;
  long long int x = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      long long int g;
      cin >> g;
      mat[i][j] = g;
      if (j == 0) x = x ^ g;
    }
    ans.push_back(1);
  }
  if (x) {
    cout << "TAK" << endl;
    for (long long int d : ans) cout << d << " ";
  } else {
    vector<long long int> v;
    long long int g = 0;
    for (long long int i = 0; i < n; i++) {
      long long int h = mat[i][0];
      long long int f = 0;
      for (long long int j = 1; j < m; j++) {
        if (mat[i][j] != h && g == 0) {
          v.push_back(j + 1);
          f = 1;
          g = 1;
        }
      }
      if (!f) v.push_back(1);
    }
    if (g) {
      cout << "TAK" << endl;
      for (long long int e : v) cout << e << " ";
    } else
      cout << "NIE";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int T;
  T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
