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
// Author: Kajetan Ramsza
#include "bits/stdc++.h"

using namespace std;

template<typename F, typename S> ostream& operator<<(ostream& os, const pair<F, S> &p) { return os<<"("<<p.first<<", "<<p.second<<")"; }
template<typename T> ostream &operator<<(ostream & os, const vector<T> &v) { os << "{"; typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) { if( it != v.begin() ) os << ", "; os << *it; } return os << "}"; }

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
    os << "[";
    typename multiset< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

void dbg_out() { cerr<<'\n'; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr<<' '<<H; dbg_out(T...); }

#ifdef DEBUG
#define dbg(...) cerr<<"(" << #__VA_ARGS__ <<"):", dbg_out(__VA_ARGS__)
#else
#define dbg(...) 
#endif

typedef long long ll;

int n, k;
vector<int> vec;

void solvek2() {
    multiset<int> left;
    multiset<int> right;
    for(int i=0;i<n;i++)
        right.insert(vec[i]);
    for(int i=0;i<n-1;i++) {
        right.erase(right.find(vec[i]));
        left.insert(vec[i]);
        int mini = *left.begin();
        int maxi = *right.rbegin();
        dbg(left, right, mini, maxi);
        if(mini >= maxi) {
            cout<<"TAK\n";
            cout<<i+1<<'\n';
            return;
        }
    }
    cout<<"NIE\n";
}

void solvek3() {
    // vector<int> sorted = vec;
    // sort(sorted.begin(), sorted.end());
    int mini = *min_element(vec.begin(), vec.end());
    int maxi = *max_element(vec.begin(), vec.end());
    dbg(mini, maxi);
    for(int i=1;i<n-1;i++) {
        if(vec[i] == mini || vec[i] == maxi) {
            cout<<"TAK\n";
            cout<<i<<' '<<i+1<<'\n';
            return;
        }
    }
    if(vec[0] == maxi) {
        cout<<"TAK\n";
        cout<<"1 2"<<'\n';
    } else if(vec[n-1] == mini) {
        cout<<"TAK\n";
        cout<<"1 "<<n-1<<'\n';
    }
    else
        cout<<"NIE\n";
}

void solvek4() {
    set<int> breaks;
    bool correct = false;
    for(int i=1;i<n;i++) {
        if(vec[i] <= vec[i-1]) {
            if(i != 1)
                breaks.insert(i-1);
            breaks.insert(i);
            if(i != n-1)
                breaks.insert(i+1);
            correct = true;
            break;
        }
    }
    if(!correct) {
        cout<<"NIE\n";
        return;
    }
    for(int i=1;i<=n;i++) {
        if((int)breaks.size() == k-1) break;
        breaks.insert(i);
    }
    cout<<"TAK\n";
    for(auto b : breaks) {
        cout<<b<<' ';
    }
    cout<<'\n';
}

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

    
    cin>>n>>k;
    vec.resize(n);
    for(auto &v : vec)
        cin>>v;

    if(k == 2) {
        solvek2();
    } else if(k == 3) {
        solvek3();
    } else {
        solvek4();
    }
}