#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  int a[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  for (int i = 0; i <= 10; i++) {
    int one = 0, zero = 0;
    map<int, pair<int, int> > s;
    for (int j = 0; j < n; j++) {
      s[j].first = -1;
      s[j].second = -1;
      for (int k = 0; k < m; k++) {
        if ((a[j][k] & (1 << i)) == 0) {
          zero++;
          s[j].first = k;
          break;
        }
      }
      for (int k = 0; k < m; k++) {
        if ((a[j][k] & (1 << i)) != 0) {
          one++;
          s[j].second = k;
          break;
        }
      }
    }
    if (one == 0) {
      continue;
    }
    if (one % 2 == 0 && zero != 0) {
      int p = -1;
      for (int j = 0; j < n; j++) {
        if (s[j].first != -1 && s[j].second != -1) {
          p = j;
          break;
        }
      }
      if (p == -1) {
        continue;
      }
      cout << "TAK" << endl;
      for (int j = 0; j < n; j++) {
        if (j == p) {
          cout << s[j].first + 1 << " ";
          continue;
        }
        if (s[j].second != -1)
          cout << s[j].second + 1 << " ";
        else
          cout << s[j].first + 1 << " ";
      }
      return 0;
    } else if (one % 2 == 1) {
      cout << "TAK" << endl;
      for (int j = 0; j < n; j++) {
        if (s[j].second != -1)
          cout << s[j].second + 1 << " ";
        else {
          cout << s[j].first + 1 << " ";
        }
      }
      return 0;
    }
  }
  cout << "NIE";
}
