#include <bits/stdc++.h>
using namespace std;
int a[505][505];
int main() {
  int n, m;
  cin >> n >> m;
  int x = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  for (int i = 0; i < n; i++) x ^= a[i][0];
  if (x) {
    cout << "TAK" << '\n';
    for (int i = 0; i < n; i++) cout << 1 << ' ';
    return cout << '\n', 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (a[i][j] != a[i][0]) {
        cout << "TAK" << '\n';
        for (int k = 0; k < n; k++)
          if (k == i)
            cout << j + 1 << ' ';
          else
            cout << 1 << ' ';
        return cout << '\n', 0;
      }
  cout << "NIE" << '\n';
  return 0;
}
