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
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

typedef pair<int,int> par;
priority_queue<par> q;
int tab[500009], n, k;
vector<int> v;

void solve2()
{
	int mi = 1e9+1;
	par p;
	for(int i=1; i<=n; i++) q.push(par(tab[i], i));
	for(int i=1; i<n; i++)
	{
		mi = min(mi, tab[i]);
		p = q.top();
		while(p.second <= i)
		{
			q.pop();
			p = q.top();
		}
		if(mi >= p.first)
		{
			cout<<"TAK\n"<<i;
			return;
		}
	}
	cout<<"NIE\n";
	return;
}

void solve3()
{
	int mi = 1e9 + 1, indmi, ma = -1, indma;
	for(int i=1; i<=n; i++)
	{
		if(tab[i] == mi) indmi = max(indmi, i);
		if(tab[i] < mi)
		{
			mi = tab[i];
			indmi = i;
		}
		if(tab[i] > ma)
		{
			ma = tab[i];
			indma = i;
		}
	}
	if(indmi == 1 && indma == n)
	{
		cout<<"NIE\n";
		return;
	}
	if(indmi > 1)
	{
		if(indmi == n) cout<<"TAK\n"<<n-2<<" "<<n-1;
		else cout<<"TAK\n"<<indmi-1<<" "<<indmi;
		return;
	}
	if(indma < n)
	{
		if(indma == 1) cout<<"TAK\n1 2";
		else cout<<"TAK\n"<<indma-1<<" "<<indma;
		return;
	}
	return;
}

void solve4()
{
	int a = -1, b = 1;
	for(int i=2; i<=n; i++) if(tab[i] <= tab[i-1]) a = i;
	if(a == -1)
	{
		cout<<"NIE\n";
		return;
	}
	if(a < n) v.pb(a);
	v.pb(a-1);
	if(a - 2 > 0) v.pb(a-2);
	while(v.size() < k-1)
	{
		if(b < a - 2 || b > a) v.pb(b);
		b++;
	}
	sort(v.begin(), v.end());
	cout<<"TAK\n";
	for(int i=0; i<v.size(); i++) cout<<v[i]<<" ";
	return;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>k;
	for(int i=1; i<=n; i++) cin>>tab[i];
	if(k == 2) solve2();
	else if(k == 3) solve3();
	else solve4();
	return 0;
}