97c7fed55db4553dd8e782100ec56ee49e13c52c8dcb3628cc26b655d745f50c
// https://szkopul.edu.pl/problemset/problem/EtoosPkK0NsWBseqXHAWrieT/site/?key=statement
// OIG VII (2 etap)
#include <iostream>
#include <map>
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int n, l;
std::cin >> n >> l;
std::map<int, int> naw;
int res = 0, got = 0;
for (int i = 0; i < l; i++) {
char a;
std::cin >> a;
if (a == 'D') {
res++;
} else {
naw[a - '0']++;
}
}
for (int i = 1; i <= n; i++) {
int a;
std::cin >> a;
int temp = a - naw[i];
if (temp < 0) {
std::cout << "NIE\n";
return 0;
} else {
got += temp;
}
}
if (res <= got) {
std::cout << "TAK\n";
} else {
std::cout << "NIE\n";
}
return 0;
}