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
def main():
    _, k = input().split()
    k = int(k)
    income = [int(x) for x in input().split()]
    income += [1000000001]

    i = 0
    for i in range(len(income) - 1):
        if income[i] >= income[i+1]:
            break
    income.pop(-1)

    if i == len(income) - 1:
        print("NIE")
    elif k >= 4:
        print("TAK")
        result = [x+1 for x in range(k - 1)]
        if i == k-2:
            result.pop(0)
            result.append(k)
        elif i == k-1:
            for x in range(2):
                if i + x < len(income):
                    result.pop(0)
                    result.append(i + x)
        elif i >= k:
            for x in range(3):
                if i + x < len(income):
                    result.pop(0)
                    result.append(i + x)

        print(*result)
    else:
        left_min = [0 for _ in range(len(income))]
        right_max = [0 for _ in range(len(income))]

        left_min[0] = income[0]
        for i in range(1, len(income)):
            left_min[i] = min(left_min[i-1], income[i])

        right_max[-1] = income[-1]
        for i in range(len(income) - 2, -1, -1):
            right_max[i] = max(right_max[i+1], income[i])

        if k == 2:
            for i in range(len(income) - 1):
                if left_min[i] >= right_max[i+1]:
                    print("TAK")
                    print(i+1)
                    return 0
            print("NIE")
        elif k == 3:
            for i in range(len(income) - 1):
                if income[i] >= right_max[i+1]:
                    print("TAK")
                    print(i, i+1)
                    return 0
            for i in range(1, len(income)):
                if left_min[i-1] >= income[i]:
                    print("TAK")
                    print(i, i + 1)
                    return 0
            print("NIE")


if __name__ == '__main__':
    main()