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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define pque priority_queue
#define vt vector
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define END(x) { cout << x; return; }

template<int D, typename T> struct vtd : public vector<vtd<D - 1, T>> { 
	template<typename... Args> vtd(int n = 0, Args... args) : vector<vtd<D - 1, T>>(n, vtd<D - 1, T>(args...)) {} };
template<typename T> struct vtd<1, T> : public vector<T> { vtd(int n = 0, const T& val = T()) : vector<T>(n, val) {} };

#define PI (ld)3.1415926535897932384626433832795
#define MOD (int)1000000007
#define inf (int)1000000001
#define INF (ll)1000000000000000001
#define EPS 1e-9

typedef long double ld;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#ifdef NOT_OJ
	#define debug(x) cerr << #x << ": "; __print(x); cerr << "\n";
#else
	#define debug(x)
#endif

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void __print(ll t) { cerr << t; }
void __print(int t) { cerr << t; }
void __print(string t) { cerr << t; }
void __print(char t) { cerr << t; }
void __print(ld t) { cerr << t; }
void __print(double t) { cerr << t; }
void __print(ull t) { cerr << t; }
void __print(uint t) { cerr << t; }
void __print(bool t) { cerr << t; }

template <class T, class V> void __print(pair <T, V> p);
template <class T> void __print(vt <T> v);
template <class T> void __print(set <T> v);
template <class T, class V> void __print(map <T, V> v);
template <class T> void __print(multiset <T> v);
template <class T> void __print(vt <vt <T>> v);
template <int D, class T> void __print(vt <vtd <D, T>> v);
template <class T> void __print(unordered_set <T> v);
template <class T, class V> void __print(unordered_map <T, V> v);
template <class T, class V> void __print(pair <T, V> p) {cerr << "{"; __print(p.F); cerr << ","; __print(p.S); cerr << "}";}
template <class T> void __print(vt <T> v) {cerr << "[ "; for (T i : v) {__print(i); cerr << " ";} cerr << "]";}
template <class T> void __print(vt <vt <T>> v) {cerr << "\n"; for (int i = 0; i < sz(v); i++) {cerr << "  "<< i << ": "; __print(v[i]); cerr << "\n";}}
template <int D, class T> void __print(vt <vtd <D, T>> v) {cerr << "\n"; for (int i = 0; i < sz(v); i++) {cerr << "  "<< i << ": "; __print(v[i]); cerr << "\n";}}
template <class T> void __print(set <T> v) {cerr << "[ "; for (T i : v) {__print(i); cerr << " ";} cerr << "]";}
template <class T> void __print(unordered_set <T> v) {cerr << "[ "; for (T i : v) {__print(i); cerr << " ";} cerr << "]";}
template <class T> void __print(multiset <T> v) {cerr << "[ "; for (T i : v) {__print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void __print(map <T, V> v) {cerr << "[ "; for (auto i : v) {__print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void __print(unordered_map <T, V> v) {cerr << "[ "; for (auto i : v) {__print(i); cerr << " ";} cerr << "]";}

void __runcase() {
    int n, k;
    cin >> n >> k;
    vt <int> v(n + 2);
    vt <bool> b(n + 2);
    bool found = false;
    for (int i = 1; i <= n; i++)
        cin >> v[i];
    if (k == 2) {
        vt <int> pre(n + 2, inf);
        vt <int> suf(n + 2, -inf);
        for (int i = 1; i <= n; i++)
            pre[i] = min(pre[i - 1], v[i]);
        for (int i = n; i >= 1; i--)
            suf[i] = max(suf[i + 1], v[i]);
        for (int i = 1; i < n; i++) {
            if (pre[i] >= suf[i + 1]) {
                b[i] = true;
                found = true;
                break;
            }
        }
    }
    else if (k == 3) {
        vt <int> suf(n + 2, -inf);
        vt <int> pre(n + 2, inf);
        for (int i = 1; i <= n; i++)
            pre[i] = min(pre[i - 1], v[i]);
        for (int i = n; i >= 1; i--)
            suf[i] = max(suf[i + 1], v[i]);
        for (int i = 1; i < n; i++) {
            if (v[i] >= suf[i + 1]) {
                if (i != 1) 
                    b[i - 1] = true;
                b[i] = true;
                found = true;
                break;
            }
            if (v[i + 1] <= pre[i]) {
                if (i + 1 != n)
                    b[i + 2] = true;
                b[i + 1] = true;
                found = true;
                break;
            }
        }
    }
    else {
        for (int i = 1; i < n; i++) {
            if (v[i] >= v[i + 1]) {
                if (i != 1)
                    b[i - 1] = true;
                if (i != n - 1)
                    b[i + 2] = true;
                b[i] = b[i + 1] = true;
                found = true;
                break;
            }
        }
    }
    if (found) cout << "TAK\n";
    else END("NIE\n")
    int sum = 0;
    for (int i = 1; i <= n; i++) sum += b[i];
    if (sum != k - 1) {
        for (int i = n; i >= 1; i--) {
            if (!b[i]) {
                b[i] = true;
                sum++;
                if (sum == k - 1) break;
            } 
        }
    }
    for (int i = 1; i <= n; i++) {
        if (b[i]) cout << i << " ";
    }
    cout << "\n";

}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	int __test_cases = 1;
	// cin >> __test_cases;

	while(__test_cases--) {
		__runcase();
	}
}