1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
#include <iostream>
#include <string>

using namespace std;

int zamiana (string str)
{
    if (str=="1A")
        return 1;
    if (str=="1B")
        return 2;
    if (str=="1C")
        return 3;
    if (str=="2A")
        return 4;
    if (str=="2B")
        return 5;
    if (str=="2C")
        return 6;
    if (str=="3A")
        return 7;
    if (str=="3B")
        return 8;
    if (str=="3C")
        return 9;
    if (str=="4A")
        return 10;
    if (str=="4B")
        return 11;
    if (str=="4C")
        return 12;
    if (str=="5A")
        return 13;
    if (str=="5B")
        return 14;
    if (str=="5C")
        return 15;
}

int main()
{
    int n, A1=0, B1=0, C1=0, A2=0, B2=0, C2=0, A3=0, B3=0, C3=0, A4=0, B4=0, C4=0, A5=0, B5=0, C5=0;
    string str;
    cin>>n;
    do {
        cin>>str;
        switch (zamiana(str))
        {
        case 1:
            A1++;
            break;
        case 2:
            B1++;
            break;
        case 3:
            C1++;
            break;
        case 4:
            A2++;
            break;
        case 5:
            B2++;
            break;
        case 6:
            C2++;
            break;
        case 7:
            A3++;
            break;
        case 8:
            B3++;
            break;
        case 9:
            C3++;
            break;
        case 10:
            A4++;
            break;
        case 11:
            B4++;
            break;
        case 12:
            C4++;
            break;
        case 13:
            A5++;
            break;
        case 14:
            B5++;
            break;
        case 15:
            C5++;
            break;        }
        n--;
    } while (n>0);
    if (A1>0&&A2>0&&A3>0&&A4>0&&A5>1&&B1>0&&B2>0&&B3>0&&B4>0&&B5>1&&C1>0&&C2>0&&C3>0&&C4>0&&C5>1)
        cout<<"TAK";
    else
        cout<<"NIE";
    return 0;
}