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
#include <iostream>
using namespace std;
const int N = 500 * 1000 + 4;
int n, k; int tab[N];
bool konce[N];
int minim[N]; int maksim[N];
void dwa()
{
	minim[1] = tab[1];
	for (int i = 2; i <= n; i++) minim[i] = min(tab[i], minim[i - 1]);
	maksim[n] = tab[n];
	for (int i = n - 1; i >= 1; i--) maksim[i] = max(tab[i], maksim[i + 1]);
	for (int i = 1; i <= n - 1; i++)
	{
		if (minim[i] >= maksim[i + 1])
		{
			cout << "TAK" << "\n";
			cout << i;
			return;
		}
	}
	cout << "NIE";
	return;
}
void trzy()
{
	int maks = 0; for (int i = 1; i <= n; i++) maks = max(tab[i], maks);
	for (int i = 1; i < n; i++)
	{
		if (tab[i] == maks)
		{
			cout << "TAK" << "\n";
			if (i > 1)
			{
				cout << i - 1 << " " << i;
				return;
			}
			else
			{
				cout << 1 << " " << 2;
				return;
			}
		}
	}
	minim[1] = tab[1];
	for (int i = 2; i <= n; i++) minim[i] = min(tab[i], minim[i - 1]);
	for (int i = 1; i < n-1; i++)
	{
		if (minim[i] >= tab[i + 1])
		{
			cout << "TAK" << "\n";
			cout << i << " " << i + 1;
			return;
		}
	}
	cout << "NIE";
	return;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i ++) cin >> tab[i];
	bool flaga = 0;
	for (int i = 2; i <= n; i++)
	{
		if (!flaga && tab[i] <= tab[i - 1])
		{
			flaga = 1;
			konce[i - 2] = 1;  konce[i] = 1; konce[i - 1] = 1;
			//cout << i << "\n";
		}
	}
	if (!flaga)
	{
		cout << "NIE";
		return 0;
	}
	if (k == 2)
	{
		dwa();
		return 0;
	}
	if (k == 3)
	{
		trzy();
		return 0;
	}
	if (konce[0] == 1) k++;
	if (konce[n] == 1) k++;
	konce[n] = 1; k -= 4;
	int it = 1;
	cout << "TAK" << "\n";
	while (k > 0)
	{
		if (!konce[it])
		{
			k--; konce[it] = true;
		}
		it++;
	}
	for (int i = 1; i < n; i++) if (konce[i]) cout << i << " ";
}