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
import sys

def read_input():
    n = int(sys.stdin.readline().strip())  # Read the first line as an integer
    data = [line.rsplit(' ', 1) for line in sys.stdin.readlines()]  # Read next n lines
    data = [(text, int(num)) for text, num in data]

    return n, data

# Example usage:
n, data = read_input()

first_ten = []
second_ten = []
id = 1
for row in data:
    status, number = row
    if status != "NIE":
        if len(first_ten) < 10:
            first_ten.append(str(id))
        else:
            if number < 2:
                second_ten.append(str(id))
                if len(second_ten) == 10:
                    break
    id += 1

print(" ".join(first_ten + second_ten))