#B3680. Ban-Pick Role Selection

    ID: 11339 Type: Default 1000ms 256MiB

Ban-Pick Role Selection

Ban-Pick Role Selection

In professional matches, a Ban-Pick process is carried out. There are two teams: Survivors and Hunters. The Survivors team has \(n\) characters and the Hunters team has \(m\) characters.

During the Ban phase:

  • The Hunters ban (disable) the top 5 Survivor characters with the highest proficiency.
  • The Survivors ban (disable) the top 2 Hunter characters with the highest proficiency.

After the Ban phase, the Pick phase proceeds:

  • The Survivors select 4 characters from the remaining Survivor pool (choosing the ones with the highest proficiency available).
  • The Hunters select 1 character from the remaining Hunter pool (choosing the highest proficiency available).

You are given the names, camps and players' proficiency for all characters. Output the names of the roles selected in the Pick phase for both camps.

inputFormat

The first line contains two integers \(n\) and \(m\) (the number of Survivor and Hunter characters respectively).

The following \(n\) lines each contain a Survivor character's name (a string) and an integer representing their proficiency.

The next \(m\) lines each contain a Hunter character's name and their proficiency (an integer).

outputFormat

Print two lines:

  • The first line contains the names of the 4 selected Survivor characters (separated by a single space), chosen from those remaining after the top 5 have been banned.
  • The second line contains the name of the selected Hunter character (from those remaining after the top 2 have been banned).

sample

9 3
S1 100
S2 90
S3 80
S4 70
S5 60
S6 50
S7 40
S8 30
S9 20
H1 95
H2 85
H3 75
S6 S7 S8 S9

H3

</p>