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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <utility>
#include <stack>
#include <set>

using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define MP make_pair
#define FOR(v,p,k) for(int v=(p);v<=(k);++v)
#define FORD(v,p,k) for(int v=(p);v>=(k);--v)
#define REP(i,n) for(int i=0;i<(n);++i)
#define VAR(v,i) __typeof(i) v=(i)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define PB push_back
#define ST first
#define ND second
#define SIZE(x) (int)x.size()
#define ALL(c) c.begin(),c.end()

#define ODD(x) ((x)%2)
#define EVEN(x) (!(ODD(x)))



int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    VI a;
    a.reserve(n);
    REP(i, n) {
        int aa;
        scanf("%d", &aa);
        a.PB(aa);
    }
    bool res;
    VI res_pos;
    res_pos.reserve(k);

    bool is_sorted=true;
    REP(i, n-1) {
        if (a[i] >= a[i+1]) {
            is_sorted=false;
        }
    }

    if (is_sorted) {
        res = false;
    } else if (k >= 4) {
        res = true;
        int i;
        REP(j, n-1) {
            if (a[j] >= a[j+1]) {
                i=j;
            }
        }
        VI pref, mid, suf;
        pref.reserve(k);
        mid.reserve(k);
        suf.reserve(k);

        FOR(j, i-1, i+1) {
            if (j >= 0 && j < n-1) {
                mid.PB(j);
            }
        }
        FOR(j, 0, min(i-2, n-2)) {
            if ((pref.size() + mid.size() + suf.size()) < k-1) {
                pref.PB(j);
            }
        }
        FOR(j, i+2, n-2) {
            if ((pref.size() + mid.size() + suf.size()) < k-1) {
                suf.PB(j);
            }
        }
        FOREACH(it, pref) res_pos.PB(*it);
        FOREACH(it, mid) res_pos.PB(*it);
        FOREACH(it, suf) res_pos.PB(*it);
    } else if (k==3) {
        auto min_max = minmax_element(ALL(a));
        REP(i, n-1) {
            if (a[i] == *min_max.second) {
                res=true;
                if (i==0) {
                    res_pos.PB(0);
                    res_pos.PB(1);
                } else {
                    res_pos.PB(i-1);
                    res_pos.PB(i);
                }
                break;
            }
        }
        if (res_pos.size() == 0) {
            FOR(i, 1, n-1) {
                if (a[i] == *min_max.first) {
                    res=true;
                    if (i==n-1) {
                        res_pos.PB(n-3);
                        res_pos.PB(n-2);
                    } else {
                        res_pos.PB(i-1);
                        res_pos.PB(i);
                    }
                    break;
                }
            }
        }
        if (res_pos.size() == 0) {
            res=false;
        }
    } else {
        VI suff_max;
        suff_max.reserve(n);
        suff_max.PB(a[n-1]);
        int curr=a[n-1];
        FORD(i, n-2, 0) {
            curr = max(curr, a[i]);
            suff_max.PB(curr);
        }

        curr = a[0];
        FOR(i, 1, n-1) {
            if (curr >= suff_max[n-1-i]) {
                res=true;
                res_pos.PB(i-1);
                break;
            }
            curr = min(curr, a[i]);
        }
        if (res_pos.size() == 0) {
            res=false;
        }
    }
    /**
    if (res) {
        VI v = res_pos;
        std::sort(v.begin(), v.end());
        v.erase(std::unique(v.begin(), v.end()), v.end());
        assert(v==res_pos);
        assert(v[0] >= 0);
        assert(v.back() < n-1);

        assert(res_pos.size() == k-1);

        int prev=-1;
        v.PB(n-1);
        bool found = false;
        REP(i, v.size()-1) {


            int mn = *min_element(a.begin()+prev+1, a.begin()+1+v[i]);
            int mx = *max_element(a.begin()+v[i]+1, a.begin()+1+v[i+1]);
            if (mn >= mx) found=true;
            prev = v[i];
        }
        assert(found);
    }
    */

    printf("%s\n", res ? "TAK" : "NIE");
    REP(i, res_pos.size()) {
        printf("%s%d%s", (i==0)? "": " ", res_pos[i]+1, (i==res_pos.size()-1)? "\n": "");
    }

    return 0;
}