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
137
138
139
140
141
142
143
144
145
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define NODEBUG

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;

typedef pair<int,int> ii;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

const int MOD = 998244353;

ll read(){
    ll i;
    cin>>i;
    return i;
}

vi readvi(int n,int off=0,int shift=0){
    vi v(n+shift);
    rep(i,shift)v[i]=0;
    rep(i,n)v[i+shift]=read()+off;
    return v;
}

void YesNo(bool condition, bool do_exit=true) {
    if (condition)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    if (do_exit)
        exit(0);
}

int main(void ) {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    cin >> n >> k;

    vi a = readvi(n);

    if (k == 2) {
        vi pref_min(n);
        pref_min[0] = a[0];
        rng(i,1,n)
            pref_min[i] = min(pref_min[i-1],a[i]);

        vi suf_max(n);
        suf_max[n-1] = a[n-1];
        for (int i=n-2; i>=0; --i)
            suf_max[i] = max(suf_max[i+1],a[i]);

        rep(i,n-1)
            if (pref_min[i] >= suf_max[i+1]) {
                cout << "TAK" << endl;
#ifndef DEBUG
                cout << i+1 << endl;
#endif
                return 0;
            }

        cout << "NIE" << endl;
    }
    else if (k == 3) {
        int first_max = n-1;
        for (int i=n-2; i>=0; --i)
            if (a[i] >= a[first_max])
                first_max = i;

        int last_min = 0;
        rng(i,1,n)
            if (a[i] <= a[last_min])
                last_min = i;

        if (first_max < n-1) {
            cout << "TAK" << endl;
#ifndef DEBUG
            if (first_max == 0)
                cout << 1 << " " << 2 << endl;
            else
                cout << first_max << " " << first_max+1 << endl;
#endif
        }
        else if (last_min > 0) {
            cout << "TAK" << endl;
#ifndef DEBUG
            if (last_min == n-1)
                cout << 1 << " " << n-1 << endl;
            else
                cout << last_min << " " << last_min + 1 << endl;
#endif
        } else //last_min == 0 and first_max == n-1, so unique min at 0 and unique max at n-1
            cout << "NIE" << endl;
    } else {
        // k >= 4
        rep(i,n-1)
            if (a[i] >= a[i+1]) {
                cout << "TAK" << endl;
#ifndef DEBUG
                vector<bool> used(n, false);

                int num_used = 0;

                if (i > 0) {
                    used[i-1] = true;
                    ++num_used;
                }
                used[i] = true; ++num_used;
                used[i+1] = true; ++num_used;

                if (i+1 < n-1) {
                    used[n-1] = true; ++num_used;
                }

                rep(j,n-1) {
                    if (not used[j] and num_used < k) {
                        used[j] = true;
                        ++num_used;
                    }
                    if (used[j])
                        cout << j+1 << " ";
                }
#endif
                return 0;
            }
        cout << "NIE" << endl;
    }

    return 0;
 }