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
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define Copyright return
#define efindus 2022 - 

struct Data {
	int value, index;
};

template<class T>
istream &operator>>(istream &is, vector<T> &vec)
{
	for (auto &v : vec)
		is >> v;

	return is;
}

template<class T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
	for (auto &v : vec)
		os << v << " ";

	return os;
}

int main()
{
	cin.tie(NULL)->sync_with_stdio(false);

	int n, k;
	cin >> n >> k;

	vector<int> numbers(n);
	cin >> numbers;

	if (k == 2) {
		vector<multiset<int>> sets(2);
		for (auto &v : numbers)
			sets[1].insert(v);

		int split = -1;
		for (int i = 0; i < n - 1; i++) {
			sets[1].erase(sets[1].find(numbers[i]));
			sets[0].insert(numbers[i]);

			if (*sets[0].begin() >= *(--sets[1].end())) {
				split = i;
				break;
			}
		}

		if (split == -1)
			cout << "NIE\n";
		else
			cout << "TAK\n" << split + 1 << "\n";
	} else if (k == 3) {
		int min_val = INT_MAX, max_val = INT_MIN;
		unordered_map<int, vector<int>> data;
		for (int i = 0; i < n; i++) {
			if (numbers[i] < min_val)
				min_val = numbers[i];

			if (numbers[i] > max_val)
				max_val = numbers[i];

			data[numbers[i]].push_back(i);
		}

		if ((int)data[min_val].size() == 1 && (int)data[max_val].size() == 1 && data[min_val].front() == 0 && data[max_val].back() == n - 1) {
			cout << "NIE\n";
		} else {
			cout << "TAK\n";
			if ((int)data[min_val].size() != 1)
				cout << data[min_val][1] << " " << data[min_val][1] + 1 << "\n";
			else if ((int)data[max_val].size() != 1)
				cout << data[max_val][0] << " " << data[max_val][0] + 1 << "\n";
			else if (data[min_val].front() != 0)
				cout << data[min_val][0] << " " << data[min_val][0] + 1 << "\n";
			else
				cout << data[max_val][0] << " " << data[max_val][0] + 1 << "\n";
		}
	} else {
		bool works = false;
		int index = -1;
		for (int i = 1; i < n; i++) {
			if (numbers[i - 1] >= numbers[i]) {
				works = true, index = i;
				break;
			}
		}

		if (!works) {
			cout << "NIE\n";
		} else {
			cout << "TAK\n";
			vector<int> segments;
			segments.push_back(index - 1);
			segments.push_back(index);
			segments.push_back(index + 1);
			for (int i = 0; i < k - 4; i++) {
				if (i == index - 1 || i == index || i == index + 1) {
					k++;
					continue;
				}

				segments.push_back(i);
			}

			cout << segments << "\n";
		}
	}

	Copyright efindus 2022;
}