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
//2022-12-13
//author: Marcin Rolbiecki
#include <bits/stdc++.h>
using namespace std;

const int maxN = 5e5+10;

int n, k;
int A[maxN];

int main () {
		
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	
	for (int i = 0; i < n; i++)
		cin >> A[i];
		
	if (k == 2) {
		
		int minpr[n], maxsuf[n];
		minpr[0] = A[0];
		maxsuf[n-1] = A[n-1];
		
		for (int i = 1; i < n; i++)
			minpr[i] = min(minpr[i-1], A[i]);
		
		for (int i = n-2; i >= 0; i--)
			maxsuf[i] = max(maxsuf[i+1], A[i]);
		
		for (int i = 0; i < n-1; i++)
			if (minpr[i] >= maxsuf[i+1]) {
				cout << "TAK\n" << i+1 << '\n';
				return 0;
			}
		
		cout << "NIE";
	}
	if (k == 3) {
		
		int maxx = 1, maxcnt = 0, minn = 1e9, mincnt = 0;
		
		for (int i = 0; i < n; i++) {
			
			if (A[i] == maxx) maxcnt++;
			if (A[i] == minn) mincnt++;
			if (A[i] > maxx) {
				maxx = A[i];
				maxcnt = 1;
			}
			if (A[i] < minn) {
				minn = A[i];
				mincnt = 1;
			}
		}
		
		if (A[0] == maxx) {
			cout << "TAK\n" << 1 << ' ' << 2;
			return 0;
		}
		if (A[n-1] == minn) {
			cout << "TAK\n" << n-2 << ' ' << n-1;
			return 0;
		}
		
		if (maxcnt >= 2 || maxx != A[n-1])
			for (int i = 1; i < n-1; i++)
				if (A[i] == maxx) {
					cout << "TAK\n" << i << ' ' << i+1;
					return 0;
				}
		if (mincnt >= 2 || minn != A[0])
			for (int i = 1; i < n-1; i++)
				if (A[i] == minn) {
					cout << "TAK\n" << i << ' ' << i+1;
					return 0;
				}
		
		cout << "NIE";
	}
	if (k >= 4) {
		
		if (A[0] >= A[1]) {
			cout << "TAK\n" << 1 << ' ' << 2 << ' ' << 3;
			return 0;
		}
		if (A[n-2] >= A[n-1]) {
			cout << "TAK\n" << n-3 << ' ' << n-2 << ' ' << n-1;
			return 0;
		}
		
		for (int i = 1; i < n-1; i++) {
			if (A[i] >= A[i+1]) {
				cout << "TAK\n" << i << ' ' << i+1 << ' ' << i+2;
				return 0;
			}
		}
		cout << "NIE";
	}
	
	return 0;
}