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
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

const int N = 500000 + 9;
int n;
int k;
int v[N];

void NIE() { printf("NIE\n"); }

void solve2() {
	multiset<int> a, b;
	for (int i=0; i<n; ++i) b.insert(v[i]);
	for (int i=0; i<n-1; ++i) {
		a.insert(v[i]);
		b.erase(b.find(v[i]));
		int amin = *a.begin();
		int bmax = *b.rbegin();
		if (amin >= bmax) {
			printf("TAK\n%d\n", i + 1);
			return;
		}
	}
	NIE();
}

void solve3() {
	for (int i=1; i<n-1; ++i) {
		if (v[i] <= v[0]) {
			printf("TAK\n%d %d\n", i, i+1);
			return;
		}
	}
	for (int i=n-2; i>0; --i) {
		if (v[i] >= v[n-1]) {
			printf("TAK\n%d %d\n", i, i+1);
			return;
		}
	}
	NIE();
}

void solveUnsorted(int i) {
	if (2 == k) return solve2();
	if (3 == k) return solve3();
	set<int> s;
	s.insert(i - 1);
	s.insert(i);
	s.insert(i + 1);
	s.erase(0);
	s.erase(n);
	for (int j=1; s.size()<k-1; ++j)
		s.insert(j);
	printf("TAK\n");
	for (int i=0; i<k-1; ++i) {
		printf("%d%s", *s.begin(), i<k-2 ? " " : "\n");
		s.erase(s.begin());
	}
}

void solve() {
	for (int i=1; i<n; ++i)
		if (v[i-1] >= v[i])
			return solveUnsorted(i);
	NIE();
}

int main() {
	scanf("%d%d", &n, &k);
	for (int i=0; i<n; ++i) scanf("%d", v + i);

	solve();

	return 0;
}