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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include <bits/stdc++.h>

using namespace std;

typedef long long lld;

constexpr int INF = (1<<30) - 1;
constexpr lld LINF = (1LL << 62) - 1;
constexpr int MAX_N = 1000000;

int t[MAX_N+9], mx[MAX_N+9], mn[MAX_N+9];

void solve(int test_number)
{
	int n, k;
	scanf("%d%d", &n, &k);
	if (k == 2)
	{
		mn[0] = INF;
		for (int i = 1; i <= n; ++i)
		{
			scanf("%d", &t[i]);
			mn[i] = min(mn[i-1], t[i]);
		}
		mx[n+1] = -INF;
		for (int i = 1; i <= n; ++i)
		{
			mx[i] = max(mn[i+1], t[i]);
		}
		for (int i = 2; i <= n; ++i)
		{
			if (mn[i-1] > mx[i])
			{
				printf("TAK\n%d\n", i-1);
				return;
			}
		}
		printf("NIE\n");
		return;
	}
	else
	if (k == 3)
	{
		int mn = INF;
		int mn_i = 0;
		int mx_i = 0;
		int mx = -INF;
		for (int i = 1; i <= n; ++i)
		{
			scanf("%d", &t[i]);
			if (t[i] <= mn)
			{
				mn = t[i];
				mn_i = i;	
			}
			if (t[i] > mx)
			{
				mx = t[i];
				mx_i = i;
			}
		}
		if (mn_i > 1)
		{
			printf ("TAK\n%d %d\n", mn_i-1, mn_i);
			return;
		}
		if (mx_i < n)
		{
			printf ("TAK\n%d %d\n", mx_i-1, mx_i);
			return;
		}
		printf("NIE\n");
		return;
	}
	else
	{
		int j = 0;
		t[0] = -INF;
		for (int i = 1; i <= n; ++i)
		{
			scanf("%d", &t[i]);
			if (t[i] <= t[i-1])
			{
				j = i;
			}
		}
		if (j == 0)
		{
			printf("NIE\n");
			return;
		}
		else
		{
			printf("TAK\n");
		}
		int kk = k;
		if (j == n)
		{
			j--;
		}
		if (j < 3)
		{
			j = 3;
		}
		for (int i = 1; i+2 < j; ++i)
		{
			if (kk == 4)
			{
				break;
			}
			printf("%d ", i);
			kk--;
		}
		printf("%d %d %d ", j-2, j-1, j);
		for (int i = j+1; i < n; ++i)
		{
			if (kk == 4)
			{
				break;
			}
			printf("%d ", i);
			kk--;
		}
		printf("\n");
	}
}

int main()
{
	int test_number = 1;
	// scanf("%d", &test_number);
	for (int test_id = 0; test_id < test_number; ++test_id)
	{
		solve(test_number);
	}
}