#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 105;
const int C = 101;
const int P = 11;
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int main() {
  long long n, m;
  cin >> n >> m;
  long long a[n][m];
  long long i, j;
  long long x = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) cin >> a[i][j];
  }
  for (i = 0; i < n; i++) {
    x = x ^ a[i][0];
  }
  if (x != 0) {
    cout << "TAK\n";
    for (i = 0; i < n; i++) cout << "1 ";
    return 0;
  }
  long long k;
  for (i = 0; i < n; i++) {
    for (j = 1; j < m; j++) {
      if (a[i][j] != a[i][j - 1]) {
        cout << "TAK\n";
        for (k = 0; k < n; k++) {
          if (k == i)
            cout << j + 1 << " ";
          else
            cout << "1 ";
        }
        return 0;
      }
    }
  }
  cout << "NIE";
}
