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
#include <bits/stdc++.h>

using namespace std;
using LL = long long;
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
#define ssize(x) int(x.size())

template<class A, class B> auto &operator<<(ostream &o, pair<A, B> p) {
    return o << '(' << p.first << ", " << p.second << ')';
}

template<class T> auto operator<<(ostream &o, T x) -> decltype(x.end(), o) {
    o << '{'; int i = 0; for (auto e : x) o << (", ")+2*!i++ << e;
    return o << '}';
}

#ifdef DEBUG
#define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n';
#else
#define debug(...) {}
#endif


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    REP(i, n)
        cin >> v[i];
    int inv = -1;
    FOR(i, 1, n - 1) {
        if (v[i - 1] >= v[i]) {
            inv = i;
            break;
        }
    }

    // Increasing.
    if (inv == -1) {
        cout << "NIE\n";
        return 0;
    }

    // k >= 4.
    if (k >= 4) {
        int rest = k - 2;
        vector<bool> ans(n + 1);
        ans[inv] = true;
        if (inv != 1) {
            ans[inv - 1] = true;
            rest--;
        }
        if (inv != n - 1) {
            ans[inv + 1] = true;
            rest--;
        }
        cout << "TAK\n";
        FOR(i, 1, n) {
            if (ans[i] || rest > 0) {
                cout << i << ' ';
                if (!ans[i])
                    rest--;
            }
        }
        cout << '\n';
        return 0;
    }
    
    // k = 2.
    if (k == 2) {
        vector<int> pref(n), suf(n);
        pref[0] = v[0];
        suf[n - 1] = v[n - 1];
        FOR(i, 1, n - 1) {
            pref[i] = min(pref[i - 1], v[i]);
            suf[n - i - 1] = max(suf[n - i], v[n - i - 1]);
        }
        FOR(i, 0, n - 2) {
            if (pref[i] >= suf[i + 1]) {
                cout << "TAK\n" << i + 1 << '\n';
                return 0;
            }
        }
        cout << "NIE\n";
        return 0;
    }

    // k = 3.
    int inf = (int) (1e9 + 13);
    int mn = inf, idx_mn = -1;
    int mx = -1, idx_mx = -1;
    REP(i, n) {
        if (v[i] <= mn) {
            mn = v[i];
            idx_mn = i;
        }
        if (v[i] > mx) {
            mx = v[i];
            idx_mx = i;
        }
    }

    auto print = [&](int idx) {
        if (idx == 0)
            cout << "TAK\n1 2\n";
        else if (idx == n - 1)
            cout << "TAK\n" << n - 2 << ' ' << n - 1 << '\n';
        else
            cout << "TAK\n" << idx << ' ' << idx + 1 << '\n';
    };

    if (idx_mn != 0)
        print(idx_mn);
    else if (idx_mx != n - 1)
        print(idx_mx);
    else
        cout << "NIE\n";

    return 0;
}