1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
#include <bits/stdc++.h>

using namespace std;

struct pt {
  int idx;
  int val;
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  bool isIncrIdx = 0;
  bool isConst = true;
  int curr;
  int last;
  int minBeforeMin;
  int maxAfterMin;
  cin >> curr;
  last = minBeforeMin = maxAfterMin = curr;
  pt minPt = {0, curr};
  pt minLastPt = {0, curr};
  pt maxPt = {0, curr};
  for (int i = 1; i < n; i++) {
    cin >> curr;
    if (minPt.val > curr) {
      minBeforeMin = minPt.val;
      minPt = {i, curr};
      maxAfterMin = curr;
    }
    if (maxAfterMin < curr) {
      maxAfterMin = curr;
    }
    if (maxPt.val < curr) {
      maxPt = {i, curr};
    }
    if (minLastPt.val >= curr) {
      minLastPt = {i, curr};
    }
    if (__builtin_expect(!isIncrIdx && last >= curr, 0)) {
      isIncrIdx = i;
    }
    isConst = isConst && last == curr;
    last = curr;
  }

  if (!isIncrIdx) {
    cout << "NIE\n";
    return 0;
  }

  if (isConst) {
    cout << "TAK\n";
    for (int i = 1; i < k; i++) {
      cout << i << " ";
    }
    cout << '\n';
    return 0;
  }

  // minBeforeMin is always set, as otherwise isIncr is true;
  if (k == 2) {
    if (minPt.idx == 0 || maxAfterMin > minBeforeMin) {
      cout << "NIE\n";
    } else {
      cout << "TAK\n" << minPt.idx << " \n";
    }
    return 0;
  }
  if (k == 3) {
    // cerr << "k=3; " << minLastPt.idx << " " << minLastPt.val << " " <<
    // maxPt.idx
    // << " " << maxPt.val << "\n";
    if (minLastPt.idx != 0) {
      cout << "TAK\n";
      cout << minLastPt.idx << " " << minLastPt.idx + 1 << " \n";
      return 0;
    }
    if (maxPt.idx != n - 1) {
      cout << "TAK\n";
      cout << maxPt.idx << " " << maxPt.idx + 1 << " \n";
      return 0;
    }
    cout << "NIE\n";
    return 0;
  }
  cout << "TAK\n";
  if ((isIncrIdx + 1) < k) {
    for (int i = 1; i < k; i++) {
      cout << i << " ";
    }
  } else {
    for (int i = 1; i < k - 3; i++) {
      cout << i << " ";
    }
    cout << isIncrIdx - 1 << " " << isIncrIdx << " " << isIncrIdx + 1 << " ";
  }
  cout << "\n";
}