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
132
133
134
135
#include <bits/stdc++.h>
using namespace std;template<class A,class B>auto&operator<<(ostream&o,pair<A,B>
x){return o<<'('<<x.first<<' '<<x.second<<')';}template<class T>auto operator<<(
ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++
<<e;return o<<'}';}
#ifdef DEBUG
#define LOG(x...)cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...)<<'\n';}(x)
#else
#define LOG(x...)
#endif

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int size, value;
	cin >> size >> value;

	vector<int> values(size);

	for (auto &value : values)
		cin >> value;

	vector<int> result;

	if (value == 2) {
		multiset<int> first, second;

		for (auto value : values)
			second.insert(value);

		for (int index = 0; index < size - 1; index++) {
			second.erase(second.find(values[index]));
			first.insert(values[index]);

			int first_min = *first.begin();
			int second_max = *second.rbegin();

			if (first_min >= second_max) {
				result.push_back(index);
				break;
			}
		}
	} else if (value == 3) {
		int smallest = values[0];
		int smallest_index = 0;
		int biggest = values[0];
		int biggest_index = 0;

		for (int index = 1; index < size; index++) {
			if (values[index] <= smallest) {
				smallest = values[index];
				smallest_index = index;
			}

			if (values[index] > biggest) {
				biggest = values[index];
				biggest_index = index;
			}
		}
		
		if (biggest_index != size - 1) {
			if (biggest_index == 0)
				result = { 0, 1 };
			else
				result = { biggest_index - 1, biggest_index };
		} else if (smallest_index != 0) {
			if (smallest_index == size - 1)
				result = { size - 2, size - 1 };
			else
				result = { smallest_index - 1, smallest_index };
		}
	} else {
		set<int> result_set;

		for (int index = 1; index < size; index++) {
			if (values[index - 1] < values[index])
				continue;
		
			if (index != 1)
				result_set.insert(index - 2);

			result_set.insert(index - 1);
			result_set.insert(index);

			for (int current = 0; result_set.size() < value - 1;
			     current++)
				result_set.insert(current);
			break;
		}

		for (auto value : result_set)
			result.push_back(value);
	}

	if (result.empty()) {
		cout << "NIE\n";
		return 0;
	}

	cout << "TAK\n";

	for (auto value : result)
		cout << value + 1 << ' ';

	cout << '\n';

#ifdef DEBUG
	int last = 0;
	int previous_index = 0;
	bool correct = false;

	result.push_back(size - 1);

	for (auto current_index : result) {
		int current = INT_MAX;
		
		for (int index = previous_index; index <= current_index;
		     index++)
			if (values[index] > last && values[index] < current)
				current = values[index];

		if (current == INT_MAX) {
			correct = true;
			break;
		}
		
		last = current;
		previous_index = current_index + 1;
	}

	assert(correct);
#endif
}