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
#include <bits/stdc++.h>
#define int long long
#define cln cout<<"\n---------------\n"
#define fi first
#define sec second
#define pb push_back
using namespace std;

constexpr int N = 5e5+7;
constexpr int MOD = 1e9+7;

int T[N];
pair <int, int> P[N];

bool comp (const pair <int, int> & a, const pair<int, int> & b) {
    return (a.fi==b.fi ? a.sec>b.sec : a.fi < b.fi);
}

void solve () {
    set <int> v;
    int mx = 0, mx2 = 0, mn = 1e9, mn2 = 1e9, mx2ind = 0, mn2ind = 0, mxind = 0, mnind = 0, n, k; cin>>n>>k;   
    
    for (int i=0; i<n; ++i) {
        cin>>T[i]; 
        P[i] = make_pair(T[i], i);
    }

    sort(P, P+n, comp);
    
    P[n] = {1e9+2, n};
    
    
    if (k == 2) {
		vector <int> pm(n), sm(n);
		//if (n==2 && T[0] < T[1]) {cout<<"NIE\n"; return;}
		pm[0] = T[0];
		sm[n-1] = T[n-1];
		for (int i=1; i<n; ++i) {
			pm[i] = min(pm[i-1], T[i]);
		}
		for (int i=n-2; i>=0; --i) {
			sm[i] = max(sm[i+1], T[i]);
		}
		
		for (int i=0; i<n-1; ++i) {
			if (pm[i] >= sm[i+1]) {
				cout<<"TAK\n";
				cout<<i+1;
				return;
			}
		}
		cout<<"NIE";
    }
    
    else if (k == 3) {
		if (P[0].sec != 0) {
			cout<<"TAK\n";
			cout<<P[0].sec<<' '<<P[0].sec+1;
		}
		else if (P[n-1].sec != n-1) {
			cout<<"TAK\n";
			cout<<P[n-1].sec<<' '<<P[n-1].sec+1;
		}
		else 
			cout<<"NIE\n";
	}
	
	else if (k >= 4) {
		int moment = 1e9;
		for (int i=0; i<n-1; ++i) {
            if (T[i] >= T[i+1]) {
                moment = min(moment, i);
            }
        }
		if (moment == 1e9) cout<<"NIE\n";
		else {
			cout<<"TAK\n";
            if (moment == 0) {
                v.insert(1); v.insert(2);
            }
            else if (moment == n-2) {
                v.insert(moment); v.insert(moment+1);
            }
            else {
                v.insert(moment); v.insert(moment+1); v.insert(moment+2);
            }
            int it=1;
            while (v.size() < k-1) {
                if (v.find(it) == v.end()) v.insert(it);
                it++;
            }

			for (auto x : v) cout<<x<<' ';	
		}
	}
}


int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t=1; //cin>>t;
    while (t--) {
        solve();
    }
    return 0;
}