#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 322;
const long long LINF = 2e18 + 474;
const long long MAXN = 1e5 + 228;
const long long MOD = 1e9 + 7;
const double eps = 1e-12;
int n, m;
int a[555][555], col[555];
void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans ^= a[i][0];
  }
  for (int i = 0; i < n; i++) {
    ans ^= a[i][0];
    for (int j = 0; j < m; j++) {
      if ((ans ^ a[i][j]) > 0) {
        col[i] = j;
        cout << "TAK\n";
        for (int k = 0; k < n; k++) {
          cout << col[k] + 1 << " ";
        }
        return;
      }
    }
    ans ^= a[i][0];
  }
  cout << "NIE\n";
}
int main() {
  if (!1) {
    freopen(
        "474"
        ".in",
        "r", stdin);
    freopen(
        "474"
        ".out",
        "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  setlocale(LC_ALL, "Russian");
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
