#include <bits/stdc++.h>
using namespace std;
template <class T>
int size(const T &x) {
  return x.size();
}
const int INF = ~(1 << 31);
const double pi = acos(-1);
const double EPS = 1e-9;
int main() {
  cin.sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > k;
  for (int i = (0); i < (n); i++) {
    vector<int> h(m);
    for (int j = (0); j < (m); j++) cin >> h[j];
    k.push_back(h);
  }
  for (int i = (0); i < (20); i++) {
    vector<pair<int, int> > B;
    for (int j = (0); j < (n); j++) {
      int got = 0;
      int notgot = 0;
      for (int z = (0); z < (m); z++) {
        if ((k[j][z] & (1 << i)) == 0)
          notgot = 1;
        else
          got = 1;
      }
      B.push_back(pair<int, int>(notgot, got));
    }
    int sm0 = 0, sm1 = 0;
    bool can = false;
    for (int j = (0); j < (n); j++) {
      sm0 += B[j].first;
      sm1 += B[j].second;
      if (B[j].first + B[j].second == 2) can = true;
    }
    if (can || (sm1 % 2 != 0)) {
      vector<int> ANS(n);
      int first = 0;
      for (int j = (0); j < (n); j++) {
        bool found = false;
        for (int z = (0); z < (m); z++) {
          if ((k[j][z] & (1 << i)) != 0) {
            ANS[j] = z;
            found = true;
            first++;
            break;
          }
        }
        if (!found) {
          ANS[j] = 0;
        }
      }
      if (first % 2 == 0) {
        bool otherfound = false;
        for (int j = (0); j < (n); j++) {
          if (otherfound) break;
          bool found = false;
          if (B[j].second != 0) {
            for (int z = (0); z < (m); z++) {
              if ((k[j][z] & (1 << i)) == 0) {
                ANS[j] = z;
                otherfound = true;
                break;
              }
            }
          }
        }
      }
      cout << "TAK" << endl;
      int val = 0;
      for (int j = (0); j < (ANS.size()); j++) val ^= k[j][ANS[j]];
      for (auto it = (ANS).begin(); it != (ANS).end(); ++it)
        cout << *it + 1 << " ";
      cout << endl;
      return 0;
    }
  }
  cout << "NIE" << endl;
  return 0;
}
