#include <bits/stdc++.h>
using namespace std;
const int N = 1999;
const int MOD = 1e9 + 7;
const long long INF = 1e18 + 1097;
void IOS() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int a[N][N];
int main() {
  IOS();
  int n;
  cin >> n;
  int m;
  cin >> m;
  map<int, int> make_pair[n + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      make_pair[i][a[i][j]] = j;
    }
  }
  int X = a[1][1];
  for (int i = 2; i <= n; i++) {
    X = X ^ a[i][1];
  }
  if (X > 0) {
    cout << "TAK\n";
    for (int i = 1; i <= n; i++) {
      cout << 1 << " ";
    }
  } else {
    bool ok = false;
    for (int i = 1; i <= n; i++) {
      if (make_pair[i].size() > 1) {
        ok = true;
      }
    }
    if (ok) {
      cout << "TAK\n";
      bool cur = 0;
      for (int i = 1; i <= n; i++) {
        if (!cur && make_pair[i].size() > 1) {
          cur = 1;
          int ans = a[i][1];
          for (auto x : make_pair[i]) {
            if (ans != x.first) {
              cout << x.second << "\n";
              break;
            }
          }
        } else {
          cout << 1 << " ";
        }
      }
    } else {
      cout << "NIE\n";
    }
  }
}
