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

#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define ST first
#define ND second
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef set<int> SI;
typedef long long LL;

#ifdef DEBUG
const bool debug = true;
#else
const bool debug = false;
#endif
int N, M, k, l;
const int INF = 1000 * 1000 * 1000;
const int MAKSN = 1000 * 1000 + 13;
const LL MOD = 123456789LL;

VI v;
vector<int> result;
int minPref[MAKSN], maxSuf[MAKSN];
void readIn() {
    cin >> N >> k;
    for (int i = 0; i < N; i++) {
        cin >> l;
        v.PB(l);
    }

    for (int i = 0; i < MAKSN; i++) {
        minPref[i] = v[0];
        maxSuf[i] = v.back();
    }

    for (int i = 1; i < N; i++) {
        ;
        minPref[i] = min(minPref[i - 1], v[i]);
    }

    for (int i = N - 1; i >= 0; i--) {
        maxSuf[i] = max(maxSuf[i + 1], v[i]);
    }
}

set<int> res;

void fillOutAndPrintSet() {
    k--;
    for (int i = 1; i < N && k > 0; i++) {
        if (res.find(i) == res.end()) {
            res.insert(i);
            k--;
        }
    }
    cout << "TAK"
         << "\n";
    for (auto it = res.begin(); it != res.end(); it++) {
        cout << *it << " ";
    }
    cout << "\n";
}

void solve() {
    int inw = -1;
    for (int i = 0; i < N - 1; i++) {
        if (v[i] >= v[i + 1])
            inw = i;
    }

    if (inw == -1) {
        cout << "NIE\n";
        return;
    }

    if (k == 2) {
        for (int i = 0; i < N; i++) {
            if (minPref[i] >= maxSuf[i + 1]) {
                cout << "TAK\n" << i + 1 << "\n";
                return;
            }
        }
        cout << "NIE\n";
        return;
    }
    if (k == 3) {
        for (int i = 1; i < N; i++) {
            if (v[i] <= minPref[i - 1]) {
                k--;
                res.insert(i);
                if (i + 1 < N) {
                    res.insert(i + 1);
                    k--;
                }
                fillOutAndPrintSet();
                return;
            }
        }

        for (int i = N - 2; i >= 0; i--) {
            if (v[i] >= maxSuf[i + 1]) {
                if (i > 0) {
                    res.insert(i);
                    k--;
                }
                res.insert(i + 1);
                k--;
                fillOutAndPrintSet();
                return;
            }
        }

        cout << "NO\n";
        return;
    }

    if (k >= 4) {
        if (inw > 0) {
            res.insert(inw);
            k--;
        }
        for (int i = 1; i <= 2; i++) {
            if (inw + i < N) {
                res.insert(inw + i);
                k--;
            }
        }
        fillOutAndPrintSet();
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    readIn();
    solve();
    return 0;
}