#include <bits/stdc++.h>
using namespace std;
int n, m, a[501][501];
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    int firstValue = a[i][1];
    for (int j = 2; j <= m; ++j) {
      if (firstValue != a[i][j]) {
        int temp = 0;
        for (int k = 1; k <= n; ++k) {
          if (k != i) {
            temp = temp ^ a[k][1];
          }
        }
        int posRowI = 1;
        if (temp == firstValue) {
          posRowI = j;
        }
        cout << "TAK" << endl;
        for (int k = 1; k <= n; ++k) {
          if (k != i) {
            cout << 1 << " ";
          } else
            cout << posRowI << " ";
        }
        cout << endl;
        return;
      }
    }
  }
  int temp = 0;
  for (int i = 1; i <= n; ++i) {
    temp = temp ^ a[i][1];
  }
  if (temp == 0) {
    cout << "NIE" << endl;
    return;
  }
  cout << "TAK" << endl;
  for (int i = 1; i <= n; ++i) {
    cout << 1 << " ";
  }
  cout << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
