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
#include<bits/stdc++.h>
using namespace std;

#define MAX_N 1000007
#define MAX_A 1000000007

int n, k;
int split_front = -MAX_A;

int incomes[MAX_N];
int min_from_L[MAX_N];
int max_from_R[MAX_N];

int main() {

    ios_base::sync_with_stdio(false);
    
    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        cin >> incomes[i];
    }
    
    min_from_L[0] = incomes[0];
    max_from_R[n - 1] = incomes[n - 1];

    for (int i = 1; i < n; i++) {
        min_from_L[i] = min(min_from_L[i - 1], incomes[i]);
    }

    for (int i = n - 2; i >= 0; i--) {
        max_from_R[i] = max(max_from_R[i + 1], incomes[i]);
    }

    if (k == 2) {
        for (int i = 0; i < n - 1; i++) {
            if (min_from_L[i] >= max_from_R[i + 1]) {
                cout << "TAK\n" << i + 1;
                return 0;
            }
        }

        cout << "NIE\n";
        return 0;
    }

    if (k == 3) {
        for (int i = 0; i < n - 1; i++) {
            if (min_from_L[i] >= incomes[i + 1]) {
                split_front = i;
            }
            if (incomes[i] >= max_from_R[i + 1]) {
                split_front = i - 1;
            }
        }
        split_front++;

        if (split_front < 0) {
            cout << "NIE\n";
        }
        else {
            split_front = max(1, min(split_front, n - 2));
            cout << "TAK\n" << split_front << " " << split_front + 1 << " ";
        }
        return 0;
    }

    // k > 3
    int splits = k - 1;

    for (int i = 0; i < n - 1; i++) {
        if (incomes[i] >= incomes[i + 1]) {
            split_front = i;
        }
    }
    split_front++;

    if (split_front < 0) {
        cout << "NIE\n";
        return 0;
    }

    cout << "TAK\n";

    if (split_front == 1) {
        for (int i = 1; i <= splits; i++) {
            cout << i << " ";
        }
        return 0;
    }
    if (split_front == n - 1) {
        splits -= 2;
        for (int i = 1; i < split_front - 1 && splits; i++) {
            cout << i << " ";
            splits--;
        }
        cout << split_front - 1 << " " << split_front << " ";
        return 0;
    }
    
    splits -= 3;

    for (int i = 1; i < split_front - 1 && splits; i++) {
        cout << i << " ";
        splits--;
    }

    cout << split_front - 1 << " " << split_front << " " << split_front + 1 << " ";

    for (int i = split_front + 2; i < n && splits; i++) {
        cout << i << " ";
        splits--;
    }

    return 0;
}