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
#!/usr/bin/env python3
# coding=utf-8

# Copyright (C) 2022  Paweł Widera
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details:
# http://www.gnu.org/licenses/gpl.html

import sys
import numpy


n, k = map(int, input().split())
revenues = numpy.array(input().split(), dtype=int)

is_sorted = all(revenues[i] <= revenues[i + 1] for i in range(len(revenues) - 1))
has_ties = any(revenues[i] == revenues[i + 1] for i in range(len(revenues) - 1))


def add_ties(i):
	ends = set()
	if i > 0:
		ends.add(i)
	ends.add(i + 1)
	if i + 2 < n:
		ends.add(i + 2)
	return ends


def show_example(ends):
	print("TAK")
	print(*ends)
	sys.exit()


def extend(ends, k):
	extra = [i for i in range(1, n) if i not in ends]
	ends.update(extra[:k - len(ends)])
	return ends


if is_sorted and not has_ties:
	print("NIE")
	sys.exit()

if k == 2:
	min_left = numpy.minimum.accumulate(revenues)
	max_right = numpy.maximum.accumulate(revenues[::-1])[::-1]

	for i in range(1, n):
		if min_left[i - 1] >= max_right[i]:
			show_example([i])

	print("NIE")
	sys.exit()

# ties at the beginning or at the end
if k == 3 and has_ties:
	if revenues[0] == revenues[1]:
		show_example(add_ties(0))

	if revenues[-2] == revenues[-1]:
		show_example(add_ties(-2))

# ties in the middle
if k > 3 and has_ties:
	for i in range(len(revenues) - 1):
		if revenues[i] == revenues[i + 1]:
			ends = add_ties(i)
			show_example(extend(ends, k))

# isolate leftmost max value
i = revenues.argmax()
if i < n - 1:
	ends = {i, i + 1}
	show_example(extend(ends, k))

# max is last -> reduce all rigthmost maxes
start_k = k
ends = set()

maxes = revenues.argsort()
max_index = n - 2
while max_index >= 0 and maxes[max_index] == max_index:
	max_index -= 1

ends.add(max_index + 1)

if k > 3:
	i = maxes[max_index]
	ends.update([i, i + 1])
	if len(ends) > start_k - 1:
		print("NIE")
		sys.exit()
	else:
		show_example(extend(ends, k))

# final k == 2 case
min_left = numpy.minimum.accumulate(revenues[:max_index + 1])
max_right = numpy.maximum.accumulate(revenues[max_index::-1])[::-1]

for i in range(1, max_index + 1):
	if min_left[i - 1] >= max_right[i]:
		ends.add(i)
		if len(ends) > start_k - 1:
			print("NIE")
			sys.exit()
		else:
			show_example(ends)

print("NIE")