Under construction

Still being built. Things may change

APC2shake!

Interview

Time limit2sMemory limit1024 MB

Summary
Pick up to 10 enrolled participants with no ICPC award and no past shake! top-3 finish, ranked by 2024 APC placement, and list their names sorted.
Level

Easy3 of 10

Topics
Sorting, Implementation
Solved
No attempts yet

Problem

At the 2024 Ajou University Programming Contest (2024 APC) Division 1, participants with strong results earn tickets to the 2024 Gyeongin Regional Six-University Programming Contest (2024 shake!). Qualifiers for 2024 shake! are selected by the following rules.

  • Currently enrolled undergraduate students of Ajou University
  • Not a past winner of the International Collegiate Programming Contest (ICPC)
  • Not a past top-3 winner of shake!
  • Among participants who satisfy the three rules above, up to 1010 participants with the best 2024 APC results

Given the names, enrollment status, past ICPC award status, best past shake! placement, and 2024 APC results of all participants, find the qualifiers for 2024 shake!.

Input

The first line contains the number of participants NN. (1≤N≤104)(1\leq N \leq 10^{4})

The next NN lines each contain the following information in this order, separated by spaces.

  • Name: a string of lowercase English letters with no spaces. The length of the name does not exceed 1010.
  • Enrollment status: jaehak if the participant is currently enrolled, hewhak if on leave.
  • Past ICPC award status: winner if the participant has won an ICPC award, notyet if not.
  • Best past shake! placement: an integer SS, the best placement the participant has ever achieved in shake!. −1-1 means the participant has never qualified for shake!. (1≤S≤104)(1\leq S \leq 10^4)
  • 2024 APC result: an integer AA, the final placement in the 2024 APC. (1≤A≤N)(1\leq A \leq N)

More than one participant may have the same name. No two participants have the same 2024 APC placement.

Output

The first line prints the number of qualifiers MM who can take part in 2024 shake!.

The next MM lines print the names of the qualifiers in lexicographic order.

Examples1

  1. Example 1

    Input
    20
    kim jaehak winner 5 16
    park jaehak notyet -1 18
    choi hewhak winner 10 17
    lee jaehak notyet 20 19
    kimyu hewhak notyet 30 20
    parkyu jaehak winner -1 15
    choiyu hewhak notyet 1 14
    leeyu jaehak notyet 9 12
    baek jaehak notyet 8 11
    shin jaehak notyet 4 13
    han jaehak notyet 4 8
    oh jaehak notyet 3 9
    jang hewhak notyet -1 7
    pang jaehak winner 2 10
    jaegal jaehak notyet 14 6
    sunwoo jaehak notyet 11 5
    yang hewhak notyet -1 3
    yoon jaehak winner 12 4
    moon hewhak notyet -1 2
    no hewhak winner 30 1
    
    Expected output
    8
    baek
    han
    jaegal
    lee
    leeyu
    park
    shin
    sunwoo