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
import sys


def main():
    lines = sys.stdin.read().splitlines()
    n, k = map(int, lines[0].split(" "))
    a = list(map(int, lines[1].strip().split(" ")))
    minl = [0] * n
    maxr = [0] * n
    minl[0] = a[0]
    maxr[n - 1] = a[n - 1]
    for i in range(1, n):
        minl[i] = min(minl[i - 1], a[i])
        maxr[n - i - 1] = max(maxr[n - i], a[n - i])
    if k == 2:
        for i in range(1, n):
            if minl[i - 1] >= maxr[i]:
                print("TAK")
                print(i)
                return
    elif k == 3:
        for i in range(1, n - 1):
            if a[i] <= minl[i - 1] or a[i] >= maxr[i + 1]:
                print("TAK")
                print(i, i + 1)
                return
    else:
        for i in range(1, n - 2):
            if a[i + 1] <= a[i]:
                l = range(1, min(k - 4, i - 1) + 1)
                r = range(i + 3, i + 3 + (k - 4 - len(l)))
                print("TAK",i+1,i+2)
                print(*l, i, i + 1, i + 2, *r)
                return
    print("NIE")


if __name__ == "__main__":
    main()