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
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <iostream>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <numeric>
#include <ctime>

using namespace std;
typedef long long LL;
#define INF 1000000000
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define FS first
#define SD second
#define MP make_pair
#define ZERO(t) memset(t, 0, sizeof(t))
#define MINUS(t) memset(t, -1, sizeof(t))
#define MOD 1000000007
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
#define MAX_N 500005

vector<int> v;
bool END[MAX_N];
map<int, int> M;

void solve2() {
  FOR(i,0,SZ(v)) M[v[i]]++;
  int m = 0;
  FOR(i,0,SZ(v)-1) {
    int a = v[i];
    auto it = M.find(a);
    it->second -= 1;
    if (it->second == 0) M.erase(it);
    if (i == 0) m = a;
    else m = MIN(m, a);
    
    it = M.upper_bound(m);
    if (it == M.end()) {
      printf("TAK\n");
      printf("%d\n", i + 1);
      return;
    }
  }
  printf("NIE\n");
}


void solve3() {
  FOR(i,1,SZ(v)-1) {
    if (v[i] <= v[0]) {
      printf("TAK\n");
      printf("%d %d\n", i, i + 1);
      return;
    }
  }
  if (v.back() <= v[0]) {
    printf("TAK\n"); 
    printf("%d %d\n", 1, SZ(v) - 1);
    return;
  } 
  int m = v.back();
  for (int i = SZ(v) - 2; i > 0; --i) {
    if (v[i] >= m) {
      printf("TAK\n");
      printf("%d %d\n", i, i + 1);
      return;
    }
    m = MAX(v[i], m);
  }
  printf("NIE\n");
}

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  bool inc = true;
  
  FOR(i,0,n) {
    int a; scanf("%d", &a);
    if (i > 0 && a <= v.back()) inc = false;
    v.push_back(a);
  }
  
  if (inc) {
    printf("NIE\n");
    return 0;
  }
  if (k == 2) solve2();
  else if (k == 3) solve3();
  else {
    END[n - 1] = true;--k;
    printf("TAK\n");
    FOR(i,1,n) {
       if (v[i] <= v[i - 1]) {
         if (i != n - 1) {
           END[i] = true;--k;
         }
         END[i - 1] = true;--k;
         if (i - 2 >= 0) {
           END[i - 2] = true;
           --k;
         }
         break;
       }
    }
    FOR(i,0,n) {
      if (k > 0 && !END[i]) {
        END[i] = true;
        --k;
      }
    }
    FOR(i,0,n-1) {
      if (END[i]) printf("%d ", i + 1); 
    }
    printf("\n");
  }
}