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
#include<iostream>

int n, k;
const int M = 500005;
int T[M];


int min(int a, int b) {
    return a < b ? a : b;
}

int max(int a, int b) {
    return a > b ? a : b;
}

int pref_min[M];
int suf_max[M];
void solve2() {
  pref_min[0] = T[0];
  for (int i = 1; i < n; i++) {
      pref_min[i] = min(pref_min[i - 1], T[i]);
  }

  suf_max[n - 1] = T[n - 1];
  for (int i = n - 2; i >= 0; i--) {
      suf_max[i] = max(suf_max[i + 1], T[i]);
  }

  for (int i = 1; i < n; i++) {
      if (pref_min[i - 1] >= suf_max[i]) {
          std::cout << "TAK\n";
          std::cout << i << "\n";
          return;
      }
  }
  std::cout << "NIE\n";
}

void solve3() {
    for (int i = 1; i < n; i++) {
        if (T[i] <= T[0]) {
            std::cout << "TAK\n";
            int x = (i + 1 == n) ? i - 1 : i;
            std::cout << x << " " << x + 1 << "\n";
            return;
        }
    }

    for (int i = n - 2; i >= 0; i--) {
        if (T[i] >= T[n - 1]) {
            std::cout << "TAK\n";
            std::cout << i << " " << i + 1 << "\n";
            return;
        }
    }

    std::cout << "NIE\n";
}

void solve4() {
    for (int i = 1; i < n; i++) {
        if (T[i - 1] >= T[i]) {
            std::cout << "TAK\n";
            if (i + 1 <= k) {
                for (int j = 1; j < k; j++) {
                    std::cout << j << " ";
                }
                std::cout << "\n";
            } else {
                for (int j = 1; j <= k - 4; j++) {
                    std::cout << j << " ";
                }
                std::cout << i - 1 << " " << i << " " << i + 1 << " " << i + 2 << "\n";
            }
            return;
        }
    }
    std::cout << "NIE\n";
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    std::cin >> n >> k;
    for (int i = 0; i < n; i++) {
        std::cin >> T[i];
    }

    if (k == 2) {
        solve2();
    } else if (k == 3) {
        solve3();
    } else {
        solve4();
    }

    return 0;
}