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
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
typedef long long ll;

void solve2(ll n)
{
    vector<ll> v(n);
    vector<ll> mx(n + 1);
    vector<ll> mn(n + 1);
    for (int i = 0; i < n; ++i) cin >> v[i];

    mn[0] = v[0];
    for (int i = 0; i < n; ++i)
        mn[1 + i] = min(mn[i], v[i]);

    mx[n] = v[n-1];
    for (int i = 0; i < n; ++i)
        mx[n - i - 1] = max(mx[n - i], v[n - i - 1]);

    for (int i = 1; i < n; ++i) {
        if (mn[i] >= mx[i]) {
            cout << "TAK" << endl;
            cout << i << endl;
            return;
        }
    }

    cout << "NIE" << endl;
}

void solve3(ll n)
{
    vector<ll> v(n);
    vector<ll> mx(n + 1);
    vector<ll> mn(n + 1);
    for (int i = 0; i < n; ++i) cin >> v[i];

    mn[0] = v[0];
    for (int i = 0; i < n; ++i)
        mn[1 + i] = min(mn[i], v[i]);

    mx[n] = v[n-1];
    for (int i = 0; i < n; ++i)
        mx[n - i - 1] = max(mx[n - i], v[n - i - 1]);


    for (int i = 1; i < n-1; ++i) {
        if (mn[i] >= v[i] || v[i] >= mx[i+1]) {
            cout << "TAK" << endl;
            cout << i << ' ' << i + 1 << endl;
            return;
        }
    }

    cout << "NIE" << endl;
}

void solve4(ll n)
{
    vector<ll> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i];

    for (int i = 0; i < n-1; ++i) {
        if (v[i] >= v[i+1]) {
            if (i == 0) i++;
            else if (i + 2 == n) i--;
            cout << "TAK" << endl;
            cout << i << ' ' << i + 1 << ' ' << i + 2 << endl;
            return;
        }
    }

    cout << "NIE" << endl;
}

void solve(ll n, ll k)
{
    vector<ll> v(n), result;
    for (int i = 0; i < n; ++i) cin >> v[i];

    for (int i = 0; i < n-1; ++i) {
        if (v[i] >= v[i+1]) {
            cout << "TAK" << endl;
            if (i == 0) i++;
            else if (i + 2 == n) i--;

            result.pb(i);
            result.pb(i+1);
            result.pb(i+2);

            for (int j = 1; j < n && result.size() < k - 1; ++j) {
                if (j != i && j != i + 1 && j != i + 2) {
                    result.pb(j);
                }
            }

            sort(result.begin(), result.end());
            for (int j = 0; j < result.size(); ++j) {
                cout << result[j] << ' ';
            }
            return;
        }
    }

    cout << "NIE" << endl;
}


int main()
{
    ios_base::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;

    if (k == 2) {
        solve2(n);
    } else if (k == 3) {
        solve3(n);
    } else if (k == 4) {
        solve4(n);
    } else {
        solve(n, k);
    }
}