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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<set>
#include<map>
#include<queue>

using namespace std;


const int M = 500007;
vector<int> v;

bool increasing() {
    for(int i = 1; i < v.size(); i++) {
        if(v[i] <= v[i - 1]) {
            return false;
        }
    }
    return true;
}

int mn[M], mx[M];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    for(int i = 0; i < n; i ++) {
        mn[i] = 1000000007;
        mx[i] = -1000000007;
    }
    mn[0] = v[0];
    mx[n - 1] = v[n - 1];
    for(int i = 1; i < n; i++) {
        mn[i] = min(mn[i - 1], v[i]);
    }
    for(int i = n - 2; i >= 0; i--) {
        mx[i] = max(mx[i + 1], v[i]);
    }

    if(increasing()) {
        cout << "NIE\n" << endl;
        return 0;
    }
    if(k == 2) {
        // pref suf i brut
        bool ok = false;
        for(int i = 0; i < n - 1; i++) {
            if(mn[i] >= mx[i + 1]) {
                cout << "TAK\n";
                cout << i + 1 << "\n";
                return 0;
            }
        }
        cout << "NIE\n";
    }
    if(k == 3) {

        int min_inside = 1000000007;
        int max_inside = -1000000007;
        int mn_index = -1;
        int mx_index = -1;

        for(int i = 1; i < n - 1; i++) {
            if(v[i] < min_inside) {
                min_inside = v[i];
                mn_index = i;
            }
            if(v[i] > max_inside) {
                max_inside = v[i];
                mx_index = i;
            }
        }

        if(mn[mn_index - 1] >= v[mn_index] || v[mn_index] >= mx[mn_index + 1]) {
            cout << "TAK\n";
            cout << mn_index << " " << mn_index + 1 << "\n";
            return 0;
        }
        if(mn[mx_index - 1] >= v[mx_index] || v[mx_index] >= mx[mx_index + 1]) {
            cout << "TAK\n";
            cout << mx_index << " " << mx_index + 1 << "\n";
            return 0;
        }
        cout << "NIE\n";
        return 0;
    }
    if(k >= 4) {
        int index = -1;
        for(int i = 0; i < n - 1; i ++) {
            if(v[i] >= v[i + 1]) {
                index = i + 1;
                break;
            }
        }
        if(index == 1) {
            cout << "TAK\n";
            cout << index << " " << index + 1 << " ";
            int cnt = 2;
            while(cnt < k - 1) {
                cout << cnt + 1 << " ";
                cnt ++;
            }
            return 0;
        }
        if(index == n - 1) {
            cout << "TAK\n";
            int cnt = 1;
            while(cnt < k - 1) {
                cout << cnt << " ";
                cnt ++;
            }
            cout << index << " ";
            return 0;
        }
        int cnt = 3;
        int ind = 1;
        while(cnt < k - 1 && ind < index - 1) {
            cout << ind << " ";
            ind ++;
            cnt ++;
        }
        cout << index - 1 << " " << index << " " << index + 1 << " ";
        ind = index + 2;
        while(cnt < k - 1) {
            cout << ind << " ";
            ind ++;
            cnt ++;
        }
        return 0;
    }

    return 0;
}