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
#include <bits/stdc++.h>
#define boost                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
using namespace std;
const int MAXN = 500005;
int a[MAXN], min_pref[MAXN], max_suf[MAXN];
int n, k;

deque<int> ans;

void nie() {
    cout << "NIE\n";
    exit(0);
}

void check() {
    assert(ans.size() == k - 1);
    vector<vector<int>> blocks;
    ans.push_back(n);
    int l = 1;
    for (auto r : ans) {
        blocks.push_back({});
        for (int i = l; i <= r; i++) {
            blocks.back().push_back(a[i]);
        }
        l = r + 1;
    }

    int current_max = 0;
    vector<int> result;
    for (auto v : blocks) {
        int new_best = 2e9;
        int new_best_idx = 0;
        for (auto val : v) {
            if (val > current_max) {
                new_best = min(new_best, val);
            }
        }
        current_max = new_best;
        if (new_best == 2e9) {
            return;
        }
    }

    assert(false);
}

void tak() {
    cout << "TAK\n";

    for (auto i : ans) cout << i << " ";
    cout << "\n";
    // check();
    exit(0);
}

int32_t main() {
    boost;
    cin >> n >> k;

    min_pref[0] = 2e9;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        min_pref[i] = min(min_pref[i - 1], a[i]);
    }

    for (int i = n; i >= 1; i--) {
        max_suf[i] = max(max_suf[i + 1], a[i]);
    }

    if (k >= 4) {
        for (int i = 1; i < n; i++) {
            if (a[i] >= a[i + 1]) {
                ans = {i, i + 1};
                int bins_left = k - 3;
                while (bins_left > 0 && ans.front() - 1 > 0) {
                    ans.push_front(ans.front() - 1);
                    bins_left--;
                }
                while (bins_left > 0) {
                    ans.push_back(ans.back() + 1);
                    bins_left--;
                }

                tak();
            }
        }
        nie();
    }

    if (k == 3) {
        for (int i = 1; i <= n; i++) {
            if (i < n && a[i] == max_suf[1]) {
                ans = {i};
                if (i > 1)
                    ans.push_front(i - 1);
                else
                    ans.push_back(i + 1);
                tak();
            }

            if (i > 1 && a[i] == min_pref[n]) {
                ans = {i - 1, i};
                tak();
            }
        }

        nie();
    }

    for (int i = 1; i < n; i++) {
        if (min_pref[i] >= max_suf[i + 1]) {
            ans = {i};
            tak();
        }
    }

    nie();
}