#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long a[n + 3][m + 3];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (long long k = 0; k < 12; k++) {
    vector<long long> ans;
    int counter = 0;
    for (long long i = 0; i < n; i++) {
      int flag = 0;
      for (long long j = 0; j < m; j++) {
        if ((a[i][j] & (1 << (k))) == 0) {
          flag = 1;
          ans.push_back(j);
          break;
        }
      }
      if (flag == 0) {
        for (long long j = 0; j < m; j++) {
          if ((a[i][j] & (1 << (k))) > 0) {
            counter++;
            ans.push_back(j);
            break;
          }
        }
      }
    }
    if (counter % 2 == 1) {
      cout << "TAK\n";
      for (long long l = 0; l < n; l++) {
        cout << ans[l] + 1 << " ";
      }
      return 0;
    }
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        if ((a[i][j] & (1 << (k))) > 0 && (a[i][ans[i]] & (1 << (k))) == 0) {
          counter++;
          ans[i] = j;
          if (counter % 2 > 0) {
            cout << "TAK\n";
            for (long long l = 0; l < n; l++) {
              cout << ans[l] + 1 << " ";
            }
            return 0;
          }
          break;
        }
      }
    }
  }
  cout << "NIE";
  return 0;
}
