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

#ifdef DEBUG
#include "debug.h"
#else
#define debug(...) ;
#endif

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, n, m) for (int i = (n); i < (m); ++i)

#define repr(i, n) for (int i = (n) - 1; i >= 0; --i)
#define reppr(i, n, m) for (int i = (m) - 1; i >= (n); --i)

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using si = set<int>;

template <typename T, typename V> void mini(T& a, V b) {if (b < a) a = b; }
template <typename T, typename V> void maxi(T& a, V b) {if (b > a) a = b; }

si solve4(int n, int k, const vi &a) {
    si divs;

    for (int i = 1; i < n; ++i) {
        if (a[i-1] < a[i])
            continue;

        if (i-2 >= 0)
            divs.insert(i-2);
        divs.insert(i-1);
        if (i <= n-2)
            divs.insert(i);

        break;
    }

    if (divs.empty())
        return divs;

    for (int i = 0; i < n-1; ++i)
        if (divs.size() < k-1)
            divs.insert(i);

    return divs;
}

si solve2(int n, int k, const vi &a) {
    vi prefmin(n, a.front()), sufmax(n, a.back());
    for (int i = 1; i < n; ++i)     prefmin[i] = min(prefmin[i-1], a[i]);
    for (int i = n-2; i >= 0; --i)  sufmax[i] = max(sufmax[i+1], a[i]);

    for (int i = 0; i+1 < n; ++i)
        if (prefmin[i] >= sufmax[i+1])
            return {i};

    return {};
}

si solve3(int n, int k, const vi &a) {
    const int mn = *min_element(all(a));
    const int mx = *max_element(all(a));

    for (int i = 1; i < n-1; ++i)
        if (a[i] == mn || a[i] == mx)
            return {i-1, i};

    if (a.front() == mn && a.back() == mx)
        return {};
    if (a.front() == mx && a.back() == mn)
        return {0, 1};

    assert(false);
}

void solve() {
    int n, k;
    cin >> n >> k;

    vi a(n);
    for (int &i : a) cin >> i;

    si ans;
    if (k == 2)         ans = solve2(n, k, a);
    else if (k == 3)    ans = solve3(n, k, a);
    else                ans = solve4(n, k, a);

    if (ans.empty()) {
        cout << "NIE\n";
        return;
    }

    debug(ans);

    assert(ans.size() == k-1);
    assert(0 <= *ans.begin());
    assert(n-1 > *--ans.end());

    cout << "TAK\n";
    for (int i : ans) cout << i+1 << ' ';
    cout << '\n';
}

int main() {
#ifndef DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int z = 1;
    // scanf("%d", &z);
    while (z--)
        solve();
    return 0;
}