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

int n, k;
int tab[501000];
int mins[501000];
int maxs[501000];

void minmax() {
	maxs[n-1] = tab[n-1];

	for (int i = n-2; i>= 0; --i) {
		maxs[i] = max(maxs[i+1], tab[i]);
	}

	mins[0] = tab[0];
	for (int i = 1; i < n; ++i) {
		mins[i] = min(mins[i-1], tab[i]);

	}
}

// mins[....]  >= maxs[...] 
void check2() {
	for (int i = 0; i < n-1; ++i) {
		if (mins[i] >= maxs[i+1]) {
			printf("TAK\n%d\n", i+1);
			return;
		}
	}
	printf("NIE\n");
}

// Options:
// [...] [min] [rest]
// [...] [max] [rest]
void check3() {
	if (tab[0] >= tab[1]) {
		printf("TAK\n1 2\n");
		return;
	}
	for (int i = 1; i < n-1; ++i) {
		if (tab[i] <= mins[i-1]) {
			printf("TAK\n%d %d\n",i, i+1);
			return;
		}
		if (tab[i] >= maxs[i+1]) {
			printf("TAK\n%d %d\n",i, i+1);
			return;
		}
	}
	if (mins[n-2] >= tab[n-1]) {
		printf("TAK\n%d %d\n", n-2, n-1);
	}
	printf("NIE\n");
}

int ans[500100];

// Any pair A B such that B <= A
// [...] [A] [B] [...] => B <= A
void check4() {
	bool yes = false;
	int split = -1;
	for (int i = 1; i < n; ++i) {
		if (tab[i] <= tab[i-1]) {
			yes = true;
			split = i;
			// break;
		}
	}

	if (!yes) {
		printf("NIE\n");
		return;
	}
	printf("TAK\n");

	int left = k - 4;

	if (split - 1 == 0) {
		left++;
	}

	if (split + 1 >= n) {
		left++;
	}

	//printf("split: %d\n left: %d\n", split, left);
	//
	int printed = 0;

	for (int i = 1; i < n; ++i) {
		if (i == split-1 || i == split + 1 ||  i == split) {
			printf("%d ", i);
			++printed;
		} else {
			if (left > 0) {
				printf("%d ", i);
				++printed;

				--left;
			}
		}
	}
	printf("\n");

	if (printed != k-1) {
		//printf("FAIL\n");
	}
}

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &tab[i]);
	}

	minmax();

	if (k == 2) {
		check2();
	} else if (k == 3) {
		check3();
	} else if (k >= 4) {
		check4();
	}

	return 0;
}