#include <bits/stdc++.h>
#define int unsigned long long
using namespace std;
const int N = 1000010;
int n, m, a[N], x, y, cnt, sum;
char op;
signed main() {
freopen("logistics.in", "r", stdin);
freopen("logistics.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
cin >> op >> x >> y;
if (op == 'U') {
a[x] = y;
} else {
cnt = 0, sum = 0;
for (int j = 1; j <= n; j++) {
cnt += ((a[j] > y)? y: a[j]);
sum += ((0 < a[j])? 1: 0);
}
cout << ((double((double)cnt / (double)x) >= y && sum >= x)? "TAK\n": "NIE\n");
}
}
return 0;
}