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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// Mikołaj Gazeel
// I Liceum im. Bartłomieja Nowodworskiego w Krakowie

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef char i8;
typedef unsigned char u8;
typedef short i16;
typedef unsigned short u16;
typedef int i32;
typedef unsigned int u32;
typedef long long i64;
typedef unsigned long long u64;
typedef float f32; // Dont use plox
typedef long double f64;
 
#define arr array
#define vt vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define pqueue priority_queue

#define pb push_back
#define eb emplace_back

using namespace std; 

#define st first
#define nd second

#define not_divine_intellect  std::ios_base::sync_with_stdio(false); cin.tie(0)
#define satori i32 __val; cin >> __val; while(__val--)
#define rep(__val) for(i32 __temp = 0; __temp < __val; __temp++)

namespace std {
  template<typename T, typename U>
  ostream& operator<<(ostream &stream, const pair<T,U> &rhs) {
    return stream << '(' << rhs.st << ", " << rhs.nd << ')';
  }
}

#define mt make_tuple
#define mp make_pair

#define all(__arr) __arr.begin(), __arr.end()

constexpr i64 bandit = 14206902137;


#define DEBUG

bool solve(set<i32> &res, vt<i32> &orig, i32 &k, i32 n) {

  if(k == 1) {
    priority_queue<pair<i32,i32>> pq;

    for(i32 i = 0; i < n; i++) {
      pq.push(mp(orig[i], i));
    }

    i32 miner = orig[0];
    for(i32 i = 0; i < n-1; i++) {
      while(pq.top().nd <= i)
        pq.pop();

      miner = min(miner, orig[i]);

      if(pq.top().st <= miner) {
        res.insert(i+1);
        k--;
        return true;
      }
    }

    return false;
  }

  if(k == 2) {
    priority_queue<pair<i32,i32>> pq;

    for(i32 i = 0; i < n; i++) {
      pq.push(mp(orig[i], i));
    }

    for(i32 i = 0; i < n-1; i++) {
      while(pq.top().nd <= i)
        pq.pop();

      if(pq.top().st <= orig[i]) {
        if(i != 0) {
          res.insert(i);
          k--;
        }

        res.insert(i+1);
        k--;
        return true;
      }
    }

    i32 maxer = orig[0];
    i32 idx = 0;

    for(i32 i = 0; i < n; i++) {
      if(orig[i] > maxer) {
        maxer = orig[i];
        idx = i;
      }
    }

    res.insert(idx);
    k--;

    return solve(res, orig, k, idx);
  }

  for(i32 i = 0; i < n-1; i++) {
    if(orig[i] >= orig[i+1]) {
      res.insert(i+1);
      k--;

      if(n > 2 && i != n-2) {
        res.insert(i+2);
        k--;
      }

      if(i != 0) {
        res.insert(i);
        k--;
      }



      return true;
    }
  }

  return false;
}

i32 main() {
  not_divine_intellect;

  i32 n,k;
  cin >> n >> k;
  k--;

  vt<i32> q;

  rep(n) {
    i32 x;
    cin >> x;

    q.push_back(x);
  }

  set<i32> res;

  bool pass = solve(res, q, k, n);

  for(i32 i = 0; i < n && res.size() < k; i++) {
    res.insert(i);
  }

  if(pass) {
    cout << "TAK\n";
    for(i32 x : res)
      cout << x << ' ';
    cout << '\n';
  } else {
    cout << "NIE\n";
  }

}