#include <cstring>
#include <iostream>
using namespace std;
const int N = 1e6 + 6;
int a[N];
int b[N];
int main() {
freopen("logistics.in", "r", stdin);
freopen("logistics.out", "w", stdout);
int n, m;
cin >> n >> m;
while (m--) {
char op;
int x, y;
cin >> op >> x >> y;
if (op == 'U') {
a[x] = y;
} else {
int cnt = 0;
memset(b, 0, sizeof(b));
while (cnt < y) {
int s = 0;
for (int i = 1; i <= n; i++) {
if (a[i] - b[i] > 0) {
s++;
b[i]++;
if (s == x) break;
}
}
if (s != x) break;
cnt++;
}
if (cnt == y) {
cout << "TAK\n";
} else {
cout << "NIE\n";
}
}
}
return 0;
}