include <cstdio>

include <cstring>

include <cmath>

include <algorithm>

include <cstdlib>

include <vector>

include <map>

include <queue>

include <set>

include <iostream>

include <ctime>

include <bitset>

define gc getchar()

define ll long long

define il inline

define fi first

define se second

define mk make_pair

define pii pair<int, int>

define pll pair<ll, ll>

define pb push_back

define rep(i, a, b) for (int i = a; i <= b; ++i)

define repn(i, b, a) for (int i = b; i >= a; --i)

define ite iterator

define eps 1e-8

using namespace std;

template<class o> il void qr(o &x) {

x = 0; char c = gc; int f = 1;
while (c < '0' || c > '9') {if (c == '-') f = -1; c = gc;}
while (c >= '0' && c <= '9') {x = x * 10 + (c ^ 48); c = gc;}
x *= f;

}

template<class o> void qw(o x) {

if(x / 10) qw(x / 10); putchar(x % 10 + 48);

}

template<class o> void pr1(o x) {

if (x < 0) putchar('-'), x = -x;
qw(x); putchar(' ');

}

template<class o> void pr2(o x) {

if (x < 0) putchar('-'), x = -x;
qw(x); puts("");

}
/ code /
const int N = 1e6 + 5;
int fa[N], chN, val[N], siz[N], root, len, c[N]; ll v[N];

define lc chx

define rc chx

il bool son(int x) {return ch[fa[x]][1] == x;}

il void upd(int x) {siz[x] = siz[lc] + siz[rc] + c[x]; v[x] = v[lc] + v[rc] + 1ll val[x] c[x];}

il void add(int d, int f) {

fa[++len] = f; val[len] = v[len] = d; siz[len] = c[len] = 1; 
ch[len][0] = ch[len][1] = 0; if (f) ch[f][d > val[f]] = len;

}

void rotate(int x) {

int y = fa[x], z = fa[y], w = !son(x), o = ch[x][w]; ch[y][w ^ 1] = o; if (o) fa[o] = y;
if (z) ch[z][son(y)] = x; fa[x] = z; ch[x][w] = y; fa[y] = x; upd(y); upd(x);

}

void splay(int x, int rt = 0) {

if (!rt) root = x; for (int y = fa[x]; y != rt; rotate(x), y = fa[x]) 
     if (fa[y] != rt) son(x) ^ son(y) ? rotate(x) : rotate(y);

}

int get(int d) {

int x = root; while (val[x] != d) {
    if (val[x] > d && lc) x = lc;
    else if (val[x] < d && rc) x = rc;
    else break;
} return x;

}

void ins(int d) {

if (!root) {add(d, 0); root = len; return ;}
int x = get(d); 
if (val[x] == d) ++c[x], upd(x), splay(x);
else add(d, x), upd(x), splay(len);

}

void del(int d) {

int x = get(d); splay(x); if (c[x] > 1) {--c[x]; upd(x); return ;}
if (!lc && !rc) root = len = 0;
else if (lc && !rc) fa[root = lc] = 0;
else if (!lc && rc) fa[root = rc] = 0;
else {
    int y = lc; while (ch[y][1]) y = ch[y][1]; splay(y, x);
    int z = rc; ch[y][1] = z; fa[root = y] = 0; fa[z] = y; upd(y);
}

}

int nxt(int d) {

int x = get(d); splay(x);
if (val[x] <= d && rc)
    for (x = rc; lc; x = lc);
if (val[x] <= d) return -1; 
splay(x); return x;

}

int a[N];

void solve() {

int n, m; qr(n), qr(m);
rep (i, 1, n) ins(0);
rep (i, 1, m) {
    char s[5];  scanf("%s", s + 1); 
    if (s[1] == 'U') {
        int x, y; qr(x), qr(y);
        del(a[x]);
        a[x] = y; 
        ins(a[x]);    
    } else {
        int C, S; qr(C), qr(S);
        if (i == 16)
            ++i, --i;
        int x = nxt(S - 1); 
        int sum = (x == -1 ? 0 : siz[x] - siz[lc]);
        if (sum >= C) puts("TAK");
        else {
            ll w = 1ll * (C - sum) * S;
            if (w <= (x == -1 ? v[root] : v[lc])) puts("TAK");
            else puts("NIE");
        }
    }
}

}

int main() {

//freopen("16.in", "r", stdin);
//freopen("16_ans.out", "w", stdout);
//int T; qr(T); while (T--) {
    solve();
//}
return 0;

}