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
from itertools import accumulate, count

_, n = list(map(int, input().split()))
vals = list(map(int, input().split()))

def get_ranges(i):
    print("TAK")
    print(i, i+1)


def do_for_2():
    mins = list(accumulate(vals, func=min))
    maxs = list(accumulate(vals[::-1], func=max))[::-1]
    for i, mn, mx in zip(count(start=1), mins, maxs[1:]):
        if mn >= mx:
            print("TAK")
            print(i)
            break
    else:
        print("NIE")


def do_for_3():
    mx = max(vals)
    first_max = vals.index(mx)
    if first_max != len(vals) - 1:
        get_ranges(first_max)
        return
    mn = min(vals)
    last_min = len(vals) - vals[::-1].index(mn) - 1
    if last_min != 0:
        get_ranges(last_min)
        return
    print("NIE")


def do_for_4():
    k = n
    p = []
    for i, a, b in zip(count(), vals, vals[1:]):
        if a >= b:
            print("TAK")
            if i != 0:
                p.append(i)
            p.append(i+1)
            if i != len(vals) - 2:
                p.append(i+2)
            break
        if k > 4 and i != 0 or i == len(vals) - 3:
            k -= 1
            p.append(i)
    else:
        print("NIE")
        return
    print("TAK")
    #if len(p) != n - 1:
    while len(p) != n - 1:
        p.append(i + 3)
        i += 1
    print(*p)

if n == 2:
    do_for_2()
elif n == 3:
    do_for_3()
else:
    do_for_4()