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
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5e5+7;
const int INF = 1e9+7;
int minL[MAXN], maxR[MAXN];
vector<int> A;
bitset<MAXN> wyp;

int main() {
	int n, k;
	cin >> n >> k;
	A.resize(n);
	int prev = 0;
	bool ros = 1;
	int lw = INF, hi = 0;
	int ilw = -1, ihi = -1;
	for(int i = 0; i < n; ++i) {
		cin >> A[i];
		if(i) {
			minL[i] = min(minL[i-1], A[i]);
		}
		else {
			minL[i] = A[i];
		}
		if(A[i] <= lw) {
			lw = A[i];
			ilw = i;
		}
		if(A[i] >= hi) {
			hi = A[i];
			ihi = i;
		}
		
		if(A[i] <= prev) ros = 0;
		prev = A[i];
	}
	maxR[n-1] = A[n-1];
	for(int i = n - 2; i >= 0; --i) {
		maxR[i] = max(maxR[i+1], A[i]);
	}
	//cout << "LI: " << ilw << " HI: " << ihi << '\n'; 
	for(int i = 0; i < n; ++i) {
		
	}
	if(ros) {
		cout << "NIE";
		return 0;
	}

	else if(ihi == 0) {
		cout << "TAK\n";
		for(int i = 1; i <= k-1; ++i) {
			cout << i << ' ';
		}
		return 0;
	}
	else if(ilw == n - 1) {
		cout << "TAK\n";
		for(int i = 1; i <= k-1; ++i) {
			cout << n-k+i << ' ';
		}
		return 0;
	}
	else if(k == 2) {
		for(int i = 0; i < n-1; ++i) {
			if(minL[i] >= maxR[i+1]) {
				cout << "TAK\n";
				cout << i+1;
				return 0;
			}
		}
		cout << "NIE";
		return 0;
	}
	else if(k >= 3) {
		if(k == 3) {
			for(int i = 1; i < n - 1; ++i) {
				if(A[i] <= minL[i-1] || A[i] >= maxR[i+1]) {
					cout << "TAK\n";
					int x = 1;
					k -= 2;
					while(k != 1 && x < i) {
						cout << x << ' ';
						x++;
						k--;
					}
					cout << i << ' ';
					k -= x;
					cout << i+1 << ' ';
					for(int j = 1; j < k; ++j) {
						cout << i+j+1 << ' ';
					}
					return 0;
				}
			}
			cout << "NIE";
			return 0;
		}
		else {
			int poprz = 0;
			for(int i = 0; i < n; ++i) {
				if(A[i] <= poprz) {
					// i - 1 i i+1
					cout << "TAK\n";
					int x = 1;
					k -= 3;
					while(k != 1 && x < i - 1) {
						cout << x << ' ';
						x++;
						k--;
					}
					cout << i-1 << ' ' << i << ' ' << i+1 << ' ';
					k -= x;
					for(int j = 0; j <= k; ++j) {
						cout << i+j+2 << ' ';
					}
					return 0;
				}
				poprz = A[i];
			}
			cout << "NIE";
			return 0;
		}
	}
}