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
//GRT_2018
#include <bits/stdc++.h>
#define PB push_back
#define ST first
#define ND second
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

using namespace std;

using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;

const int nax = 500 * 1000 + 10;
int n, k;
int a[nax];
int suf[nax];

int strictlyInc() {
	for (int i = 2; i <= n; ++i) {
		if (a[i] <= a[i - 1]) return i;
	}
	return n + 1;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}

	int pos = strictlyInc();
	
	if (pos == n + 1) {
		cout << "NIE";
		return 0;
	}
	
	if (k >= 4) {
		cout << "TAK\n";
		set<int>ans;
		if (pos < n) {
			ans.insert(pos);
		}
		ans.insert(pos-1);
		if (pos > 2) ans.insert(pos - 2);
		for (int i = 1; i < n; ++i) {
			if ((int)ans.size() == k - 1) break;
			ans.insert(i);
		}
		for (int x : ans) cout << x << " ";
		return 0;
	}
	
	if (k == 3) {
		int mi = 1, mx = n;
		for (int i = 2; i <= n; ++i) {
			if (a[i] <= a[mi]) {
				mi = i;
			}
		}
		for (int i = n - 1; i >= 1; --i) {
			if (a[i] >= a[mx]) {
				mx = i;
			}
		}
		if (mi == 1 && mx == n) {
			cout << "NIE";
			return 0;
		}
		cout << "TAK\n";
		if (mi != 1) {
			set<int>ans;
			if (mi < n) ans.insert(mi);
			ans.insert(mi - 1);
			for (int i = 1; i < n; ++i) {
				if ((int)ans.size() == k - 1) break;
				ans.insert(i);
			}
			for (int x : ans) cout << x << " ";
		} else {
			set<int>ans;
			ans.insert(mx);
			if (mx > 1) ans.insert(mx - 1);
			for (int i = 1; i < n; ++i) {
				if ((int)ans.size() == k - 1) break;
				ans.insert(i);
			}
			for (int x : ans) cout << x << " ";
		}
		return 0;
	}
	
	suf[n] = a[n];
	for (int i = n - 1; i >= 1; --i) {
		suf[i] = max(suf[i + 1], a[i]);
	}
	int mi = a[1];
	for (int i = 1; i < n; ++i) {
		mi = min(mi, a[i]);
		if (mi >= suf[i + 1]) {
			cout << "TAK\n" << i;
			return 0;
		}	
	}
	cout << "NIE";

}