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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// Grzegorz Ryn
// Jagiellonian University

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define st first
#define nd second
#define all(__VAR) (__VAR).begin(), (__VAR).end()
#define DEBUG(__VAR) cout << #__VAR << ": " << __VAR << endl;

template <typename T, typename U>
ostream & operator<<(ostream &out, const pair<T, U> &var) {
	cout << "{" << var.st << ", " << var.nd << "}";
	return out;
}

template <typename T>
ostream & operator<<(ostream &out, const vector<T> &var) {
	cout << "[";
	for(int i=0; i<(int)var.size()-1; i++) {
		cout << var[i] << ", ";
	}
	if(var.size()>0)
		cout << var.back();
	cout << "]" << endl;
	
	return out;
}

const int inf = 1'000'000'000;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for(int i=0; i<N; i++) {
		cin >> a[i];
	}

	int first = N;
	for(int i=1; i<N; i++) {
		if(a[i] <= a[i-1]) {
			first = i-1;
		}
	}

	if(first == N) {
		cout << "NIE" << '\n';
		return 0;
	}

	if(K == 2) {
		vector<int> mx(N);
		mx[N-1] = a[N-1];
		for(int i=N-2; i>=0; i--) {
			mx[i] = max(mx[i+1], a[i]);
		}
		vector<int> mn(N);
		mn[0] = a[0];
		for(int i=1; i<N; i++) {
			mn[i] = min(mn[i-1], a[i]);
		}

		int result = N;
		for(int i=0; i<N-1; i++) {
			if(mn[i] >= mx[i+1]) {
				result = i;
				break;
			}
		}

		if(result == N) {
			cout << "NIE" << '\n';
		}
		else {
			cout << "TAK" << '\n';
			cout << result+1 << '\n';
		}

		return 0;
	}

	vector<bool> used(N, false);
	if(K >= 4) {
		used[first] = 1;
		K-=2;

		if(first+1 < N-1) {
			used[first+1] = 1;
			K--;
		}
		if(first > 0) {
			K--;
			used[first-1] = true;
		}
	}
	else if(K == 3) {
		int mn=0;
		for(int i=0; i<N; i++) {
			if(a[i] <= a[mn]) {
				mn = i;
			}
		}
		int mx=N-1;
		for(int i=N-1; i>=0; i--) {
			if(a[i] >= a[mx]) {
				mx = i;
			}
		}

		if(mn>0) {
			used[mn-1] = true;
			K -= 2;
			if(mn < N-1) {
				used[mn] = true;
				K--;
			}
		}
		else if(mx < N-1) {
			used[mx] = true;
			K -= 2;
			if(mx > 0) {
				used[mx-1] = true;
				K--;
			}
		}
		else {
			if(a[0]+1 == a[N-1]) {
				K -= 3;
				used[0] = true;
				used[N-2] = true;
			}
			else {
				cout << "NIE" << '\n';
				return 0;
			}
		}
	}

	for(int i=0; i<N && K>0; i++) {
		if(used[i]) {
			continue;
		}
		K--;
		used[i] = true;
	}

	cout << "TAK" << '\n';
	for(int i=0; i<N; i++) {
		if(used[i]) {
			cout << i+1 << ' ';
		}
	}
	cout << '\n';

	return 0;
}