#include <bits/stdc++.h>
using namespace std;
int MODU(int a, int b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}
long long int max3(long long int a, long long int b, long long int c) {
  return max(c, max(a, b));
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int max(long long int a, long long int b) { return (a > b) ? a : b; }
long long int min(long long int a, long long int b) { return (a < b) ? a : b; }
long double min(long double a, long double b) { return (a < b) ? a : b; }
long long int gcd(long long int a, long long int b) {
  if (b == 1)
    return 1;
  else if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
long long int mod(long long int x) {
  if (x >= 0)
    return x;
  else
    return -x;
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
int main() {
  int n, m;
  cin >> n >> m;
  int a[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  set<int> set1;
  bool flag = 0;
  int index1 = -1, index2 = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m - 1; j++) {
      if (a[i][j + 1] != a[i][j]) {
        flag = 1;
        index2 = j + 1;
        break;
      }
    }
    if (flag == 1) {
      index1 = i;
      break;
    }
  }
  if (flag == 0) {
    int num = 0;
    for (int i = 0; i < n; i++) {
      num = num ^ a[i][0];
    }
    if (num == 0)
      cout << "NIE" << endl;
    else {
      cout << "TAK" << endl;
      for (int i = 0; i < n; i++) cout << "1 ";
    }
  } else {
    int num = 0;
    for (int i = 0; i < n; i++) {
      num = num ^ a[i][0];
    }
    if (num != 0) {
      cout << "TAK" << endl;
      for (int i = 0; i < n; i++) cout << "1 ";
    } else {
      cout << "TAK" << endl;
      for (int i = 0; i < n; i++) {
        if (i == index1)
          cout << index2 + 1 << " ";
        else
          cout << "1 ";
      }
    }
  }
  return 0;
}
