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
#include <bits/stdc++.h>
#define qio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define ll long long 
#define st first
#define nd second
using namespace std;

int n, k, tab[500005], sufmax[500005], prefmin[500005];
int main()
{
	qio;
	cin >> n >> k;
	prefmin[0] = INT_MAX;
	for (int i = 1; i <= n; i++) {
		cin >> tab[i];
		prefmin[i] = min(prefmin[i - 1], tab[i]);
	}
	for (int i = n; i >= 1; i--) {
		sufmax[i] = max(sufmax[i + 1], tab[i]);
	}
	if (k == 2) {
		for (int i = 1; i < n; i++) {
			if (prefmin[i] >= sufmax[i + 1]) {
				cout << "TAK\n" << i << "\n";
				return 0;
			}
		}
		cout << "NIE\n";
	}
	else if (k == 3) {
		for (int i = 2; i < n; i++) {
			if (prefmin[i - 1] >= tab[i] || sufmax[i + 1] <= tab[i]) {
				cout << "TAK\n" << i - 1 << " " << i << "\n";
				return 0;
			}
		}
		cout << "NIE\n";
	}
	else {
		int res = 0;
		for (int i = 1; i < n; i++) {
			if (tab[i] >= tab[i + 1]) {
				res = i;
				break;
			}
		}
		if (res == 0) cout << "NIE\n";
		else {
			cout << "TAK\n";
			int x = 0;
			if (res == n - 1)x = max(1, res - k + 2);
			else x = max(1, res - k + 3);
			for (int i = x; i < min(n, x + k - 1); i++) cout << i << " ";
			cout << "\n";
		}
	}
}