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
#include <bits/stdc++.h>
using namespace std;


constexpr int MAXN = 500005;
int a[MAXN];

int min_pr[MAXN];
int max_sf[MAXN];

int main(){
    int n, k;
    cin >> n >> k;

    min_pr[0] = INT_MAX;

    for(int i = 1; i <= n; i++){
        cin >> a[i];
        min_pr[i] = min(min_pr[i-1], a[i]);
    }
    for(int i = n; i >= 1; i--){
        max_sf[i] = max(max_sf[i+1], a[i]);
    }
    vector<int> res;

    if(k >= 4){
        int mn = -1;
        for(int i = 1; i < n; i++){
            if(a[i] >= a[i+1]){
                mn = i;
                break;
            }
        }
        if(mn == -1){
            cout << "NIE\n";
            return 0;
        }
        int i = 1;
        for(int j = 0; j < k-4; j++){
            if(i == mn-1){
                res.push_back(mn-1);
                res.push_back(mn);
                res.push_back(mn+1);
                mn = -1;
                i += 3;
            }
            res.push_back(i);
            i++;
        }
        if(mn > 0){
            res.push_back(mn-1);
            res.push_back(mn);
            res.push_back(mn+1);
        }
        cout << "TAK\n";
        for(int i : res) cout << i << ' ';
        return 0;
    }
    
    else if(k == 3){

        for(int i = 2; i < n; i++){
            if(min_pr[i-1] >= a[i] || a[i] >= max_sf[i+1]){
                cout << "TAK\n";
                cout << i - 1 << ' ' << i << '\n';
                return 0;
            }
        }

    }
    else{
        for(int i = 1; i < n; i++){
            if(min_pr[i] >= max_sf[i+1]){
                cout << "TAK\n";
                cout << i  << '\n';
                return 0;
            }
        }

    }
    cout << "NIE\n";
    return 0;

}