#include <bits/stdc++.h>
using namespace std;
const int nmax = 500 + 7;
int m, n;
int a[nmax][nmax], x = 0;
void input() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
    }
    x ^= a[i][1];
  }
}
void solve() {
  if (x > 0) {
    cout << "TAK\n";
    for (int i = 1; i <= n; ++i) cout << 1 << " ";
  } else {
    int k = 0, pos = 0;
    for (int i = 1; i <= n; ++i) {
      if (k) break;
      for (int j = 1; j <= m; ++j) {
        if (a[i][j] != a[i][1]) k = i, pos = j;
        if (k) break;
      }
    }
    if (!k)
      cout << "NIE";
    else {
      cout << "TAK\n";
      for (int i = 1; i <= n; ++i) {
        if (i != k)
          cout << 1 << " ";
        else
          cout << pos << " ";
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  input();
  solve();
  return 0;
}
