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
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000000000000000;
long long a[500005];
long long min1[500005];
long long max2[500005];
int n,k;
void nie(){
  cout<<"NIE";
  exit(0);
}

void liczsumypref()
{
  for(int i=0; i<=n+2; i++){
      min1[i] = inf;
      max2[i] = -inf;
    }
    min1[1] = a[1];
    max2[n] = a[n];
    for(int i=2, j=n-1; i<=n; i++,j--){
      min1[i] = min(a[i],min1[i-1]);
      max2[j] = max(a[j],max2[j+1]);
    }
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin>>n>>k;
  long long maks = -inf, mini = inf;
  int maksid,minid;
  bool tak = false;
  a[0] = -1000000005;
  a[500001] = 100000000;
  int spadekid,spadekid1 = 500001;
  for(int i=1; i<=n; i++){
    cin>>a[i];
    if(a[i]<=a[i-1]){ spadekid = i; if(a[i]<a[spadekid1]) spadekid1 = i; tak = true; }
    if(a[i] > maks){
      maks = a[i];
      maksid = i;
    }
    if(a[i] <= mini){
      mini = a[i];
      minid = i;
    }
  }
  if(!tak)
    nie();
  if(k == 2){
    if(maksid == n || minid == 1) nie();
    
    liczsumypref();
    
    for(int i=1; i<n; i++)
      if(min1[i]>=max2[i+1]){
        cout<<"TAK\n"<<i;
        return 0;
      }
    nie();
  }
  //legia 
  if(k == 3){
    if(maksid == n && minid == 1)
      nie();
    if(maksid-1 == 0)
      cout<<"TAK\n"<<maksid<<' '<<maksid+1;
    else if(maksid == n)
    {
      liczsumypref();
      if(a[spadekid1] <= min1[mini-1])
        cout<<"TAK\n"<<spadekid1-1<<' '<<spadekid1;
      else
        nie();
    }
    else
      cout<<"TAK\n"<<maksid-1<<' '<<maksid;
    return 0;
  }
  cout<<"TAK\n";
  int counter = k;
  
  int f = 3;
  if(spadekid == n) f = 2;
  for(int i=1; i<spadekid-2; i++){
    if(counter == f) break;
    cout<<i<<' ';
    counter--;
  }
  if(spadekid-2 == 0){
    cout<<spadekid-1<<' '<<spadekid<<' ';
    counter--;
  }
  else if(spadekid == n){
    cout<<spadekid-2<<' '<<spadekid-1<<' ';
    counter--;
  }
  else{ 
    cout<<spadekid-2<<' '<<spadekid-1<<' '<<spadekid<<' ';
    counter-=2;
  }
  for(int i=spadekid+1; i<n; i++)
  {
    if(counter == 1) break;
    cout<<i<<' ';
    counter--;
  }
}