1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
bool can_create_set = true;
int a;
int zadania[5][3];
string s = "";
int main(){
    cin>>a;
    for(int i=0; i<a; i++){
        cin>>s;
        zadania[s[0]-'1'][s[1]-'A']++;
    }
    for(int i=0; i<3; i++){
        zadania[4][i]--;
    }
    for(int i=0; i<15; i++){
        if(zadania[i%5][i/5]<1) can_create_set = false;
    }
    string s = (can_create_set) ? "TAK" : "NIE";
    cout<<s;
}