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
#include <bits/stdc++.h>

using namespace std;

int n, k;
vector<int> a;

vector<int> solve() {
  if (k == 2) {
    vector<int> mx(n+1);
    for (int i = n-1; i >= 0; i--) {
      mx[i] = max(mx[i+1], a[i]);
    }
    int mi = INT_MAX;
    for (int i = 0; i < n-1; i++) {
      mi = min(mi, a[i]);
      if (mi >= mx[i+1]) return {i+1};
    }
  }
  else if (k == 3) {
    int mx = 0;
    int mx_i = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] > mx) { mx = a[i]; mx_i = i; }
    }
    if (mx_i == n-1) {
      vector<int> mi(a);
      mi[0] = a[0];
      for (int i = 1; i < n-1; i++) {
        mi[i] = min(mi[i-1], a[i]);
      }
      int mx2 = a[n-2];
      int mx2_i = n-2;
      for (int i = n-2; i >= 1; i--) {
        if (a[i] > mx2) {
          mx2 = a[i];
          mx2_i = i;
        }
        if (mx2 <= mi[i-1]) {
          return {i, mx2_i+1};
        }
      }
      return {};
    }
    return {mx_i, mx_i+1};
  }
  else {
    vector<int> ans;
    bool good = false;
    int start = 0;
    for (int i = 0; i < n-1; i++) {
      if (a[i] >= a[i+1]) {
        good = true;
        start = i - 1;
        break;
      }
    }
    if (good == false) return {};
    start = max(start, 0);
    start = min(start, n-k);
    for (int i = 0; i < k-1; i++) {
      ans.push_back(start + i + 1);
    }
    return ans;
  }
  return {};
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  a.resize(n);
  for (int& i : a) cin >> i;
  auto ret = solve();
  if (ret.size() < k-1) cout << "NIE\n";
  else {
    cout << "TAK\n";
    for (int i : ret) cout << i << ' ';
    cout << '\n';
  }
}