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
#include <iostream>
#include <cstdio>
#include <cstdlib>

int c;

void SKIP_WHITESPACE() {
    while (1) {
        c = fgetc(stdin);
        if (c != ' ' && c != '\n' && c != '\r')
            break;
    }
}

int READ_INT() {
    SKIP_WHITESPACE();
    int ret = c - '0';
    while (1) {
        c = fgetc(stdin);
        if (c < '0' || c > '9')
            break;
        ret = ret * 10 + c - '0';
    }
    return ret;
}

unsigned char READ_UCHAR() {
    unsigned char ret = c;
    c = fgetc(stdin);
    return ret;
}

int n, i, j, x;
unsigned char d;

int main(int argc, char* argv[]) {
    std::ios_base::sync_with_stdio (false);

    n = READ_INT();
    j = 0;
    for (i = 1; i <= n; ++i) {
        SKIP_WHITESPACE();
        d = READ_UCHAR();
        READ_UCHAR();
        READ_UCHAR();
        x = READ_INT();

        if (j < 10) {
            if (d == 'T') {
                if (j > 0)
                    std::cout << " ";
                std::cout << i;
                j++;
            }
        } else if (j < 20) {
            if (d == 'T' && x < 2) {
                std::cout << " " << i;
                j++;
            }
        }
    }
    std::cout << "\n";
    return EXIT_SUCCESS;
}