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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1000007;

vector<int> v;
int end_int[MAXN];
int maxs[MAXN];
int n, k;

bool find_asc(vector<vector<int>> fin, int x, int prev) {
	if (x == fin.size())
		return true;
	
	for (int a : fin[x]) {
		if (a > prev) {
			if (find_asc(fin, x+1, a))
				return true;
		}
	}
	
	return false;
}

void check_ans(vector<int> res) {
	res.push_back(v.size());
	assert(res.size() == k);
	
	vector<vector<int>> fin;
	
	int it = 1;
	
	for (int last : res) {
		fin.push_back({});
		
		while (it <= last) {
			fin.back().push_back(v[it-1]);
			it++;
		}
	}
	
	assert(!find_asc(fin, 0, -1));
}

int answer_no() {
	printf("NIE\n");
	return 0;
}

int answer_yes() {
	printf("TAK\n");
	vector<int> res;
	
	for (int i=0; i<v.size(); i++) {
		if (end_int[i]) {
			res.push_back(i+1);
// 			assert(i+1 < n);
		}
	}
	
// 	check_ans(res);
	
	printf("%d", res[0]);
	for (int i=1; i<res.size(); i++) {
		printf(" %d", res[i]);
	}
	printf("\n");
	return 0;
}

int is_sorted() {
	for (int i=0; i<v.size()-1; i++) {
		if (v[i] >= v[i+1])
			return i;
	}
	
	return -1;
}

int main() {
	scanf("%d%d", &n, &k);
	
	for (int i=0; i<n; i++) {
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	
	int trans = is_sorted();
	
	if (trans == -1)
		return answer_no();
	
	if (k == 2) {
		maxs[n-1] = v[n-1];
		for (int i=n-2; i>=0; i--) {
			maxs[i] = max(v[i], maxs[i+1]);
		}
		
		int minp = v[0];
		for (int i=0; i<n-1; i++) {
			minp = min(minp, v[i]);
			if (minp >= maxs[i+1]) {
				end_int[i] = 1;
				return answer_yes();
			}
		}
		
		return answer_no();
	}
	else if (k == 3) {
		for (int i=1; i<n; i++) {
			if (v[i] <= v[0]) {
				if (i == n-1)
					i--;
				end_int[i-1] = 1;
				end_int[i] = 1;
				return answer_yes();
			}
		}
		
		for (int i=n-2; i>=1; i--) {
			if (v[i] >= v[n-1]) {
				end_int[i-1] = 1;
				end_int[i] = 1;
				return answer_yes();
			}
		}
		
		return answer_no();
	}
	else {  // k >= 4
		if (trans > 0)
			trans--;
		
		int cnt = 0;
		
		for (int i=trans; i<n-1; i++) {
			end_int[i] = 1;
			cnt++;
			if (cnt == k-1)
				break;
		}
		
		for (int i=0; cnt < k-1; i++) {
			end_int[i] = 1;
			cnt++;
		}
		
		return answer_yes();
	}
	
	return 0;
}