#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long power(long long a, long long b, long long modi) {
  long long res = 1;
  while (b) {
    if (b % 2) {
      res = (res * a) % modi;
    }
    b /= 2;
    a = (a * a) % modi;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int a[n][m];
  int x = 0;
  bool flag = false;
  int row, pos1, pos2;
  ;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (j > 0 && a[i][j] != a[i][j - 1]) {
        flag = true;
        row = i;
        pos1 = j;
        pos2 = j - 1;
      }
    }
    x ^= a[i][0];
  }
  if (flag || x > 0) {
    cout << "TAK" << '\n';
    if (x > 0) {
      for (int i = 0; i < n; i++) cout << 1 << " ";
    } else {
      for (int i = 0; i < n; i++) {
        if (i == row) {
          if (a[row][pos1] != a[row][0])
            cout << pos1 + 1 << " ";
          else
            cout << pos2 + 1 << " ";
        } else
          cout << 1 << " ";
      }
    }
  } else
    cout << "NIE";
  return 0;
}
