1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import sys

n = int(sys.stdin.readline().strip())

lines = sys.stdin.read().splitlines()  
ans_list = []
count = 0

for i in range(n):
    if count == 20:
        break  

    word, wbeen = lines[i].split()[:2]  # Read first two words efficiently

    if word == "TAK":
        if count <= 10 or (count <= 19 and int(wbeen) <= 1):
            ans_list.append(str(i + 1))
            count += 1

print(" ".join(ans_list))