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
127
128
129
130
131
132
133
134
135
136
#include <iostream>
#include <vector>

using namespace std;

vector<int> get_pref_min(vector<int> const & vec) {
    vector<int> result = vec;
    for(int i = 1; i < result.size(); i++) {
        if(result[i-1] < result[i])
            result[i] = result[i-1];
    }
    return result;
}

vector<int> get_suf_max(vector<int> const & vec) {
    vector<int> result = vec;
    for(int i = result.size()-2; i >= 0; i--) {
        if(result[i+1] > result[i])
            result[i] = result[i+1];
    }
    return result;
}

bool get_result_2(vector<int> const & vec, vector<bool> & result) {
    vector<int> pref_min = get_pref_min(vec);
    vector<int> suf_max = get_suf_max(vec);

    for(int i = 0; i < vec.size()-1; i++) {
        if(pref_min[i] >= suf_max[i+1]) {
            result[i] = true;
            return true;
        }
    }

    return false;
}

bool get_result_3(vector<int> const & vec, vector<bool> & result) {
    vector<int> pref_min = get_pref_min(vec);
    vector<int> suf_max = get_suf_max(vec);

    for(int i = 1; i < vec.size()-1; i++) {
        if(vec[i] <= pref_min[i-1] || vec[i] >= suf_max[i+1]) {
            result[i] = true;
            result[i-1] = true;
            return true;
        }
    }

    if(vec[vec.size()-1] <= pref_min[vec.size()-2]) {
        result[vec.size()-2] = true;
        result[vec.size()-3] = true;
        return true;
    }
    
    return false;
}

bool get_result_lrg(vector<int> const & vec, int k, vector<bool> & result) {
    int inv_ind = -1;

    for(int i = 1; i < vec.size(); i++) {
        if(vec[i-1] >= vec[i]) {
            inv_ind = i;
            break;
        }
    }

    if(inv_ind == -1)
        return false;

    k--;

    result[inv_ind-1] = true;
    k--;

    if(inv_ind < vec.size()-1) {
        result[inv_ind] = true;
        k--;
    }   
    
    for(int i = inv_ind-2; i >= 0 && k > 0; i--) {
        result[i] = true;
        k--;
    }

    for(int i = inv_ind+1; i < vec.size() && k > 0; i++) {
        result[i] = true;
        k--;
    }

    
    return true;
}

bool get_result(vector<int> const & vec, int const k, vector<bool> & result) {
    if(k == 2) {
        return get_result_2(vec, result);
    } else if(k == 3) {
        return get_result_3(vec, result);
    } else {
        return get_result_lrg(vec, k, result);
    }
}


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

    vector<int> vec(n);

    for(int i = 0; i < n; i++) {
        cin >> vec[i];
    }

    vector<bool> result(n, false);
    if(get_result(vec, k, result)) {
        cout << "TAK\n";
        for(int i = 0; i < result.size(); i++)
            if(result[i])
                cout << i+1 << " ";
        cout << "\n";
    } else {
        cout << "NIE\n";
    }
}

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

    solve();

    return 0;
}