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
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 500500;
int n, k;
int a[N], b[N];
pii t[N];

void solved(vi ans) {
	if (SZ(ans) == 0) {
		printf("NIE\n");
		exit(0);
	}
	vi tmp = ans;
	ans = {};
	FOR(i,SZ(tmp)) if (tmp[i] >= 0 && tmp[i] < n-1) ans.pb(tmp[i]);
	sort(ans.begin(), ans.end());
	while(SZ(ans) < k-1) {
		ans.pb(ans.back() == n-2 ? 0 : ans.back()+1);
	}
	printf("TAK\n");
	sort(ans.begin(), ans.end());
	FOR(i,k-1) printf("%d ", ans[i]+1);
	printf("\n");
	exit(0);
}

int main() {
	scanf("%d%d", &n, &k);
	FOR(i,n) scanf("%d", &a[i]);
	FOR(i,n) t[i] = mp(a[i], -i);
	sort(t, t+n);
	FOR(i,n) b[-t[i].se] = i;
	//FOR(i,n) fprintf(stderr, "%d ", b[i]); fprintf(stderr,"\n");
	int decr = -1;
	FOR(i,n-1) if (b[i] > b[i+1]) decr = i;
	if (decr == -1) solved({});
	if (k >= 4) solved({decr, decr+1, decr-1});
	if (k == 3) {
		if (b[0] != 0) solved({-t[0].se-1, -t[0].se});
		if (b[n-1] != n-1) solved({-t[n-1].se-1, -t[n-1].se});
		solved({});
	}
	// k=2
	int mn = n+1;
	FOR(i,n-1) {
		mn = min(mn, b[i]);
		if (mn+i == n-1) solved({i});
	}
	solved({});
	return 0;
}

/*

6 3
3 5 4 8 3 7
TAK 3 5

4 2
2 3 2 3
NIE

*/