#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const double PI = acos(-1);
const double EPS = 1e-9;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  int mt[n][m];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mt[i][j];
      if (j == 0) {
        ans ^= mt[i][j];
      }
    }
  }
  if (ans > 0) {
    cout << "TAK\n";
    for (int i = 0; i < n; i++) {
      cout << 1;
      if (i == n - 1)
        cout << endl;
      else
        cout << " ";
    }
  } else {
    ii res(-1, -1);
    for (int i = 0; i < n; i++) {
      for (int j = 1; j < m; j++) {
        int kk = ans ^ mt[i][0] ^ mt[i][j];
        if (kk > 0) {
          res.first = i;
          res.second = j;
        }
      }
    }
    int aa = ans ^ 1 ^ 0;
    if (res.first >= 0)
      ans = ans ^ mt[res.first][0] ^ mt[res.first][res.second];
    if (ans > 0) {
      cout << "TAK\n";
      for (int i = 0; i < n; i++) {
        if (i == res.first)
          cout << res.second + 1;
        else
          cout << 1;
        if (i == n - 1)
          cout << endl;
        else
          cout << " ";
      }
    } else {
      cout << "NIE\n";
    }
  }
}
