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
#include <cstdio>

int i,n,k,tab[500001],mintab[500001],maxtab[500001];

void solve2(){
	mintab[0]=tab[0];
	for(i=1;i<n;i++){
		if(tab[i]<mintab[i-1])
			mintab[i]=tab[i];
		else
			mintab[i]=mintab[i-1];
	}
	
	maxtab[n-1]=tab[n-1];
	for(i=n-2;i>=0;i--){
		if(tab[i]>maxtab[i+1])
			maxtab[i]=tab[i];
		else
			maxtab[i]=maxtab[i+1];
	}
	for(i=0;i<n-1;i++){
		if(mintab[i]>=maxtab[i+1]){
			printf("TAK\n");
			printf("%d",i+1);
			return;
		}
	}
	printf("NIE\n");
}

void solve4(){
	int idx=-1,spare=k-1;
	for(i=0;i<n-1;i++){
		if(tab[i]>=tab[i+1]){
			idx=i;
		}
	}
	if(idx == -1){
		printf("NIE\n");
		return;
	}
	if(idx == 0 || idx == n-2){
		spare-=2;
	}
	else{
		spare-=3;
	}
	
	printf("TAK\n");
	for(i=0;i<=n-1;i++){
		if(i==idx){
			if(i==0){
				printf("%d %d ",1,2);
				i+=2;
			}
			else if(i==n-2){
				printf("%d %d",n-2,n-1);
				i+=2;
			}
			else{
				printf("%d %d %d ",i,i+1,i+2);
				i+=2;
			}
		}
		else if(spare>0 && i>0){
			spare--;
			printf("%d ",i);
		}
	}
	
}

void solve3(){
	int minind=0, maxind=n-1;
	for(i=1;i<n;i++){
		if(tab[i]<=tab[0]){
			minind=i;
			break;
		}
	}
	
	for(i=n-2;i>=0;i--){
		if(tab[i]>=tab[n-1]){
			maxind=i;
			break;
		}
	}
	if(minind==0 && maxind==n-1){
		printf("NIE\n");
		return;
	}
	
	printf("TAK\n");
	if(minind!=0){
		if(minind==n-1){
			printf("%d %d",n-2,n-1);
		}
		else{
			printf("%d %d",minind,minind+1);
		}
	}
	else{
		if(maxind==0){
			printf("%d %d",1,2);
		}
		else{
			printf("%d %d",maxind,maxind+1);
		}
	}
	
}


int main(){
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&tab[i]);
	}
	if(k==2){
		solve2();
	}
	else if(k==3){
		solve3();
	}
	else{
		solve4();
	}
	return 0;
}