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
#include <cstdio>
#include <vector>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REPD(i,n) FORD(i,0,n)
#define VAR(v,w) __typeof(w) v=(w)
#define FORE(it,c) for(VAR(it,(c).begin());it!=(c).end();++it)
#define PB push_back
#define INT(x) int x; scanf("%d", &x)

typedef vector<int> VI;

int a[500000], mi[500000], ma[500000];
bool c[500000];

int main() {
	INT(n);
	INT(k);
	REP(i,n) scanf("%d", &a[i]);
	bool asc = 1;
	int x = 0;
	REP(i,n-1) if (a[i] >= a[i + 1]) {
		x = i;
		asc = 0;
		break;
	}
	if (asc) {
		printf("NIE\n");
		return 0;
	}
	if (k == 2) {
		mi[0] = 2000000000;
		FOR(i,1,n) mi[i] = min(mi[i - 1], a[i - 1]);
		ma[n - 1] = a[n - 1];
		REPD(i,n-1) ma[i] = max(ma[i + 1], a[i]);
		FOR(i,1,n) if (mi[i] >= ma[i]) {
			printf("TAK\n%d\n", i);
			return 0;
		}
		printf("NIE\n");
		return 0;
	}
	VI v;
	if (k == 3) {
		x = -1;
		FOR(i,1,n) if (a[i] <= a[0]) {
			x = i;
			break;
		}
		if (x < 0) REPD(i,n-1) if (a[i] >= a[n - 1]) {
			x = i;
			break;
		}
		if (x < 0) {
			printf("NIE\n");
			return 0;
		}
		v.PB(x);
		v.PB(x + 1);
	} else  {
		v.PB(x);
		v.PB(x + 1);
		v.PB(x + 2);
	}
	FORE(it,v) if (*it > 0 && *it < n) {
		c[*it] = 1;
		--k;
	}
	v.clear();
	--k;
	FOR(i,1,n) {
		if (!k) break;
		if (!c[i]) {
			c[i] = 1;
			--k;
		}
	}
	printf("TAK\n");
	bool start = 1;
	FOR(i,1,n) if (c[i]) {
		if (!start) printf(" ");
		start = 0;
		printf("%d", i);
	}
	printf("\n");
}