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
import sys
input = sys.stdin.readline
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=10**10
t=False
if k>3:
    for i in range(n-1):
        if a[i+1]<=a[i]:
            t=True
            break
    if t:
        print('TAK')
        if i==n-2:
            for j in range(n-k+1,n):
                print(j,end=" ")
        elif i+2<k:
            for j in range(1,k):
                print(j,end=" ")
        else:
            for j in range(i-k+4,i+3):
                print(j,end=" ")              
    else:
        print('NIE')
elif k==3:
    q=False
    s=False
    am=a[0]
    ap=a[-1]
    if am>=ap:
        print("TAK")
        print(1,n-1)
    else:
        for i in range(1,n-1):
            if a[i]<=am:
                q=True
                break
        if not q:
            for i in reversed(range(1,n-1)):
                if a[i]>=ap:
                    q=True
                    break
        if q :
            print("TAK")
            print(i,i+1)
        else:
            print("NIE")
else:
    am=[b]
    ap=[-b]  
    for i in range(n):
        am.append(min(a[i],am[-1]))
    for i in reversed(range(n)):
        ap.append(max(a[i],ap[-1]))
    t=True
    for i in range(1,n):
        if am[i]>=ap[-i-1]:
            print("TAK")
            print(i)
            t=False
            break
    if t:
        print("NIE")