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 <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
#include <deque>
using namespace std;

#define assert_range(x,a,b) assert((a) <= (x) and (x) <= (b))
using ll = long long;
const int INF = 1e9+10;

const int MAX_N = 5*1e5+10;
int a[MAX_N];
int n, k;

void ans_yes(deque<int> v) {
    for (int i = 1; i < v.size(); ++i) {
        assert(v[i-1] < v[i]);
    }
    int left_v = v.front();
    int right_v = v.back();

    for (int x = left_v-1; v.size() < k-1 && x >= 0; --x) {
        v.push_front(x);
    }
    for (int x = right_v+1; v.size() < k-1 && x < n-1; ++x) {
        v.push_back(x);
    }
    printf("TAK\n");
    assert(v.size() == k-1);
    for (int i = 0; i < k-1; ++i) {
        printf("%d ", v[i]+1);
        assert(0 <= v[i] && v[i] < n-1);
        if (i > 0) assert(v[i-1] < v[i]);
    }
    printf("\n");
}

void ans_no() {
    printf("NIE\n");
}

void solve2() {
    vector<pair<int, int>> R(n);
    for (int i = 0; i < n; ++i) {
        R[i] = {a[i], i};
    }
    sort(R.begin(), R.end());
    int min_l = INF;
    int j = n-1;
    for (int i = 0; i < n-1; ++i) {
        while (R[j].second <= i) {
            --j;
        }
        min_l = min(min_l, a[i]);
        if (min_l >= R[j].first) {
            ans_yes({i});
            return;
        }
    }
    ans_no();
}

void solve3() {
    int min_v = *min_element(a, a+n);
    int max_v = *max_element(a, a+n);
    vector<int> pos_min, pos_max;
    for (int i = 0; i < n; ++i) {
        if (a[i] == min_v) {
            pos_min.push_back(i);
        }
        if (a[i] == max_v) {
            pos_max.push_back(i);
        }
    }
    if (pos_min.size() > 1 || pos_min[0] > 0) {
        int i = pos_min[0] > 0 ? pos_min[0] : pos_min[1];
        if (i == n-1) {
            ans_yes({i-1});
        } else {
            ans_yes({i-1, i});
        }
    } else if (pos_max.size() > 1 || pos_max[0] < n-1) {
        int i = pos_max[0] < n-1 ? pos_max[0] : pos_max[1];
        if (i == 0) {
            ans_yes({i});
        } else {
            ans_yes({i-1, i});
        }
    } else {
        ans_no();
    }
}

void solve4plus() {
    for (int i = 0; i < n-1; ++i) {
        if (a[i] >= a[i+1]) {
            if (i == 0) {
                ans_yes({i, i+1});
            } else if (i == n-2) {
                ans_yes({i-1, i});
            } else {
                ans_yes({i-1, i, i+1});
            }
            return;
        }
    }
    ans_no();
}

int main() {
    //int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    if (k == 2) {
        solve2();
    } else if (k == 3) {
        solve3();
    } else {
        solve4plus();
    }
    
    return 0;
}