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
#include<bits/stdc++.h>
 
#define pb push_back
#define f first
#define s second
#define turbo ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vll vector<pll>
#define vii vector<pii>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vb>
#define mid (l+r)/2
#define endl '\n'
#define lowbit(x) x&(-x)
#define bits(x) __builtin_popcount(x) 
#define mins(se) (*se.begin())
#define maxs(se) (*--se.end())

using namespace std;

int main() {
    turbo
    int n, k; cin >> n >> k;
    vi v(n);
    for(auto &it : v)
        cin >> it;

    if(k == 2) {
        multiset<int> one, two;
        one.insert(v[0]);
        for(int i = 1; i < n; i++)
            two.insert(v[i]);

        bool senko = false; int dzie = -1;
        for(int i = 1; i < n; i++) {
            if(mins(one) >= maxs(two)) {
                senko = true;
                dzie = i;
                break;
            }
            two.erase(two.find(v[i]));
            one.insert(v[i]);
        }
        if(senko) {
            cout << "TAK\n";
            cout << dzie;
        }
        else 
            cout << "NIE\n";

        return 0;
    }

    if(k == 3) {
        multiset<int> one, two;
        one.insert(v[0]);

        for(int i = 1; i < n; i++)
            two.insert(v[i]);

        bool senko = false; int dzie = -1;
        for(int i = 1; i < n-1; i++) {
            two.erase(two.find(v[i]));
            if(mins(one) >= v[i] or maxs(two) <= v[i]) {
                senko = true;
                dzie = i;
                break;
            }
            one.insert(v[i]);
        }

        if(senko) {
            cout << "TAK\n";
            cout << dzie << " " << dzie+1;
        }
        else 
            cout << "NIE\n";

        return 0;
    }

    bool senko = false; int dzie = -1;
    for(int i = 1; i < n; i++)
        if(v[i-1] >= v[i]) {
            senko = true;
            dzie = i;
            break;
        }
    
    if(!senko) {
        cout << "NIE\n";
        return 0;
    }

    cout << "TAK\n";

    vb ciach(n);
    ciach[dzie-1] = true;
    k-=2;
    if(dzie+1 != n) {
        ciach[dzie] = true;
        k--;
    }
    if(dzie-1 > 0) {
        ciach[dzie-2] = true;
        k--;
    }

    for(int i = 0; i < n-1 and k; i++) 
        if(!ciach[i]) {
            ciach[i] = true;
            k--;
        }

    for(int i = 0; i < n; i++)
        if(ciach[i])
            cout << i+1 << " ";
}