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
#include <iostream>
#include <vector>
#include <list>

using namespace std;

int n, k;
vector<int> t;

void solve_2() {
  vector<int> sm(n + 1);
  sm[n] = t[n - 1] - 1;
  for (int i = n; --i >= 0;)
    sm[i] = max(sm[i + 1], t[i]);

  int tmp = sm[0];
  for (int i = 0; i < n - 1; i++) {
    tmp = min(tmp, t[i]);
    if (tmp >= sm[i + 1]) {
      cout << "TAK\n" << i + 1 << '\n';
      return;
    }
  }
  cout << "NIE\n";
}

void solve_3() {
  for (int i = 1; i < n - 1; i++) {
    if (t[0] >= t[i]) {
      cout << "TAK\n";
      cout << i << ' ' << i + 1;
      return;
    }
  }

  for (int i = n - 2; i > 0; i--) {
    if (t[i] >= t[n - 1]) {
      cout << "TAK\n";
      cout << i << ' ' << i + 1;
      return;
    }
  }

  cout << "NIE\n";
}

void solve_xd() {
  list<int> l;
  for (int i = 1; i < n; i++) {
    if (t[i - 1] >= t[i]) {
      l.push_back(i);
      l.push_back(i + 1);
      break;
    }
  }

  while (l.size() < k - 1 && l.front() - 1 > 0)
    l.push_front(l.front() - 1);

  while (l.size() < k - 1 && l.back() < n)
    l.push_back(l.back() + 1);

  cout << "TAK\n";
  for (auto x : l)
    cout << x << ' ';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);

  cin >> n >> k;
  t.resize(n, 0);

  bool inc = true;
  int prev = -1e9;

  for (auto &x : t) {
    cin >> x;
    if (x <= prev)
      inc = false;
    prev = x;
  }

  if (inc) {
    cout << "NIE\n";
    return 0;
  }

  if (k == 1) {
    cout << "TAK\n";
  } else if (k == 2) {
    solve_2();
  } else if (k == 3) {
    solve_3();
  } else {
    solve_xd();
  }
}