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
#include <bits/stdc++.h>
using namespace std;
namespace debug { template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> char spk(...); template <class c> auto spk(c* a) -> decltype(cerr << *a, 0); struct stream { ~stream() { cerr << endl; } template <class c> typename enable_if <sizeof spk<c>(0) != 1, stream&>::type operator<<(c i) { cerr << boolalpha << i; return *this; } template <class c> typename enable_if <sizeof spk<c>(0) == 1, stream&>::type operator<<(c i) { return *this << range(begin(i), end(i)); } template <class a, class b> stream& operator<<(pair <a,b> p) { return *this << "(" << p.first << ", " << p.second << ")"; } template <class c> stream& operator<<(rge<c> d) { *this << "["; for (auto it=d.b; it!=d.e; it++) *this << ", " + 2 * (it == d.b) << *it; return *this << "]"; } stream& _dbg(const string& s, int i, int b) { return *this; } template <class c, class ... cs> stream& _dbg(const string& s, int i, int b, c arg, cs ... args) { if (i == (int)(s.size())) return (*this << ": " << arg); b += (s[i] == '(') + (s[i] == '[') + (s[i] == '{') - (s[i] == ')') - (s[i] == ']') - (s[i] == '}'); return (s[i] == ',' && b == 0) ? (*this << ": " << arg << "     ")._dbg(s, i + 1, b, args...) : (s[i] == ' ' ? *this : *this << s[i])._dbg(s, i + 1, b, arg, args...); } };}
#define dout debug::stream()
#define dbg(...) ((dout << ">> ")._dbg(#__VA_ARGS__, 0, 0, __VA_ARGS__))
#define st first
#define nd second
#define pb push_back
#define all(x) x.begin(),x.end()
#define ss(x) ((int)((x).size()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lowb(v,x) (lower_bound(all(v),(x))-v.begin())
#define uppb(v,x) (upper_bound(all(v),(x))-v.begin())
#define erase_duplicates(x) {sort(all(x));x.resize(unique(all(x))-x.begin());}
template <class p, class q> pair<p,q> operator-(pair<p,q> a, pair<p,q> b) { return mp(a.f - b.f, a.s - b.s); }
template <class p, class q> pair<p,q> operator+(pair<p,q> a, pair<p,q> b) { return mp(a.f + b.f, a.s + b.s); }
template <class p, class q> void umin(p &a, const q &b) { if (a > b) a = b; }
template <class p, class q> void umax(p &a, const q &b) { if (a < b) a = b; }
using lf=long double;
using ll=long long;
using cll=const ll;
using cint=const int;
using pll=pair<ll,ll>;
using pii=pair<int,int>;

int const maxN=5e5+10;
int n, k;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n>>k;
    vector<int>sufmax(n, INT_MAX), prefmin(n, -INT_MAX), v(n);
    for(int i=0; i<n; i++) cin>>v[i];
    prefmin[0]=v[0];
    sufmax[n-1]=v[n-1];
    for(int i=1; i<n; i++) prefmin[i]=min(prefmin[i-1], v[i]);
    for(int i=n-2; i>=0; i--) sufmax[i]=max(sufmax[i+1], v[i]);
    if(k==2){
        for(int i=0; i+1<n; i++){
            if(prefmin[i]>=sufmax[i+1]){
                cout<<"TAK\n";
                cout<<i+1<<"\n";
                return 0;
            }
        }
        cout<<"NIE\n";
        return 0;
    }
    int pt=-1;
    for(int i=0; i<n; i++){
        if((i-1>=0 && prefmin[i-1]>=v[i]) || (i+1<n && sufmax[i+1]<=v[i])){
            pt=i;
            break;
        }
    }
    if(pt==-1){
        cout<<"NIE\n";
        return 0;
    }
    cout<<"TAK\n";
    k=k-2-(pt>0 && pt<n-1);
    int lst=-1;
    for(int i=0; i<n && k; i++){
        if(i!=pt && i!=pt-1) k--;
        cout<<i+1<<' ';
        lst=i;
    }
    if(lst<pt-1) cout<<pt<<" "<<pt+1<<'\n';
    else if(lst<pt) cout<<pt+1<<'\n';
}
/*
g++ -std=c++11 -DLOCAL -Wall -Wextra -Wconversion -Wshadow -Wno-sign-conversion -D_GLIBCXX_DEBUG -fno-sanitize-recover=undefined -fsanitize=undefined -DPRAYFORSOLVE -fsanitize=address

*/