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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef LOCAL
#define debug(...) __VA_ARGS__
#else
#define debug(...) {}
#endif
int n,k;
int tab[500010];
void solve4(){
    int gdzie = -1;
    for (int i = 1; i < n; i++){
        if (tab[i] >= tab[i+1]){
            gdzie = i;
        }
    } 
    if (gdzie == -1){
        cout<<"NIE\n"; 
        return;
    }
    cout<<"TAK\n";
    k -= 3;
    vector<int> wy;
    if (gdzie+1 == n){
        k++;
    }
    for (int i = gdzie-1; i ; i--){
        if (k){
            wy.push_back(i);
            k--;
        }       
    }   
    reverse(wy.begin(),wy.end());
    wy.push_back(gdzie);
    if (gdzie+1 != n){
        wy.push_back(gdzie+1);
    }   
    for (int i = gdzie+2; i < n; i++){
        if (k){
            wy.push_back(i);
            k--;
        }
    }
    for (int j : wy) cout<<j<<" ";
    cout<<"\n";
    return;
}
void solve3(){
    int gdzieminn = 1;
    for (int i = 1; i < n; i++){
        if (tab[i] <= tab[gdzieminn]){
            gdzieminn = i;
        }
    }
    if (gdzieminn != 1){
        cout<<"TAK\n";
        cout<<gdzieminn-1<<" "<<gdzieminn<<"\n";
        return;
    }
    int gdziemaxx = n;
    for (int i = n-1; i > 1 ; i--){
        if (tab[i] >= tab[gdziemaxx]){
            gdziemaxx = i;
        }   
    }
    if (gdziemaxx != n){
        cout<<"TAK\n";
        cout<<gdziemaxx-1<<" "<<gdziemaxx<<"\n";
        return;
    }   
    cout<<"NIE\n";
    return;
}
void solve2(){
    int suf[n+1];
    suf[n] = tab[n];
    for (int i = n-1; i ; i--){
        suf[i] = max(suf[i+1],tab[i]);
    } 
    int minn = tab[1];
    int wy = -1;
    for (int i = 1; i < n; i++){
        if (minn >= suf[i+1]){
            wy = i;
        } 
        minn = min(minn,tab[i+1]);
    }
    if (wy == -1) cout<<"NIE\n";
    else{
        cout<<"TAK\n";
        cout<<wy<<"\n";
    }
    return;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int i;
    cin>>n>>k;
    for (i = 1; i < n+1; i++) cin>>tab[i];
    if (k >= 4){
        solve4();
        return 0;
    }
    if (k == 3){
        solve3();
        return 0;
    }
    solve2();
    return 0;
}