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

using namespace std;
#define endl '\n'
#define fi first
#define sc second
#define LL long long

vector<int> Tab;
int divide(int n){
	int Rmax = 0, Lmin = Tab[0];
	multiset<int> Liczby;
	for(int i = 0; i < n; i++){
		Rmax = max(Rmax, Tab[i]);
		Liczby.insert(Tab[i]);
	}
	for(int i = 1; i < n; i++){
		Liczby.erase(Liczby.lower_bound(Tab[i-1]));
		Lmin = min(Lmin, Tab[i-1]);
		auto It = Liczby.end(); It--;
		Rmax = *It;
//		for(auto x : Liczby) cout << x << " ";
//		cout << endl;
		if(Lmin >= Rmax) return i;
	}
	return -1;
}
void ct(int isol, int k){
	k -= 2;
	for(int i = 1; i <= k-1; i++){
		cout << i << " ";
	}
	if(isol > k) cout << isol - 1 << " " << isol << " ";
	else if(isol == k) cout << isol << " " << isol+1 << " ";
	else cout << k+1 << " " << k+2 << " ";
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int N, k;
	cin >> N >> k;
	Tab.resize(N);
	for(int i = 0; i < N; i++){
		int a; cin >> a;
		Tab[i] = a;
	}
	if(k == 2){
		int res = divide(N);
		if(res == -1){
			cout << "NIE" << endl;
		}
		else{
			cout << "TAK" << endl;
			cout << res << endl;
		}
		return 0;
	}
	else{
		int n = N; int isol = -1; int brak = N;
		priority_queue<pair<int, int>> Q;
		for(int i = 0; i < N; i++){
			Q.push(make_pair(Tab[i], -i));
		}
//		if(-Q.top().sc != N-1){
//			isol = -Q.top().sc; isol++;
//			ct(isol, k);
//		}
		while(!Q.empty() && -Q.top().sc == n-1){
			Q.pop();
			n--;
		}
		if(Q.empty()){
			cout << "NIE" << endl;
			return 0;
		}
		brak = n;
		if(brak != N) k--;
		isol = -Q.top().sc; isol++;
		if(k == 2){
			if(divide(n) == -1) cout << "NIE" << endl;
			else{
				cout << "TAK" << endl;
				cout << divide(n) << " " << brak << endl;
			}
		}
		else{
			cout << "TAK" << endl;
			ct(isol, k); 
			if(brak != N) cout << brak << " " << endl;
		}
	}
	return 0;
}