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
#include <bits/stdc++.h>
#define dbg(x) " [" << #x << ": " << (x) << "] "
using namespace std;
template<typename A, typename B>
ostream& operator<<(ostream& out, const pair<A,B>& p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& c) {
    out << "{";
    for(auto it = c.begin(); it != c.end(); it++) {
        if(it != c.begin()) out << ", ";
        out << *it;
    }
    return out << "}";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for(int& i : v) cin >> i;
    if(k == 2) {
        vector<int> mn(n, 1e9 + 1);
        mn[0] = v[0];
        for(int i = 1; i < n; i++) mn[i] = min(mn[i - 1], v[i]);
        int mx = 0;
        for(int i = n - 1; i > 0; i--) {
            mx = max(mx, v[i]);
            if(mn[i - 1] >= mx) {
                cout << "TAK" << endl << i << endl;
                return 0;
            }
        }
        cout << "NIE" << endl;
    } else if(k >= 4) {
        int j = -1;
        for(int i = 1; i < n; i++) {
            if(v[i - 1] >= v[i]) {
                j = i - 1;
            }
        }
        if(j == -1) {
            cout << "NIE" << endl;
        } else if(j == n - 2) {
            cout << "TAK" << endl;
            for(int i = 0; i < k - 1; i++) {
                if(i) cout << " ";
                cout << n - k + 1 + i;
            }
            cout << endl;
        } else if(j == 0) {
            cout << "TAK" << endl;
            for(int i = 0; i < k - 1; i++) {
                if(i) cout << " ";
                cout << i + 1;
            }
            cout << endl;
        } else {
            if(j + 1 < k - 1) {
                cout << "TAK" << endl;
                for(int i = 0; i < k - 1; i++) {
                    if(i) cout << " ";
                    cout << i + 1;
                }
                cout << endl;
            } else {
                cout << "TAK" << endl;
                for(int i = 0; i < k - 1; i++) {
                    if(i) cout << " ";
                    cout << j - k + 4 + i;
                }
                cout << endl;
            }
        }
    } else {
        int mn = *min_element(v.begin(), v.end());
        int mx = *max_element(v.begin(), v.end());
        int j;
        for(int i = 0; i < n; i++) {
            if(v[i] == mn) {
                j = i;
            }
        }
        if(j != 0) {
            cout << "TAK" << endl;
            if(j < n - 1) {
                cout << j << " " << j + 1 << endl;
            } else {
                cout << n - 2 << " " << n - 1 << endl;
            }
        } else {
            for(int i = 0; i < n; i++) {
                if(v[i] == mx) {
                    j = i;
                    break;
                }
            }
            if(j == n - 1) {
                cout << "NIE" << endl;
            } else {
                cout << "TAK" << endl;
                cout << j << " " << j + 1 << endl;
            }
        }
    }
    return 0;
}