Problem X
Cards Sorting
Languages
en
is

Atli owns a terrible amount of cards and sometimes he has trouble keeping them all organised. Thus he was thinking it might be good to create a digital database to keep track of it all.
The database has to offer different ways to sort the cards. To do this we should first consider the information that each card has.
Each card has a name, for example “Bláeygður Hvítur Dreki” or “Dimmur Seiðkarl”. The names always contain only English letters along with spaces, and have length at most $32$. The names do not start or end with spaces and are not empty. Each card also has a $8$ digit ID number, for example 55144522. No two different cards have the same ID. Each card also has a type and possibly a subtype. We give the types and subtypes in the order they should be sorted here below, they are
-
Skrimsli
-
Venjulegt
-
Ahrifa
-
Bodunar
-
Samruna
-
Samstillt
-
Thaeo
-
Penduls
-
Tengis
-
-
Galdur
-
Venjulegur
-
Bunadar
-
Svida
-
Samfelldur
-
Bodunar
-
Hradur
-
-
Gildra
-
Venjuleg
-
Samfelld
-
Mot
-
-
Annad
This means Skrimsli has the subtype Thaeo, which comes before the subtype Tengis and so on. Furthermore Gildra comes after Galdur no matter what subtype it is. Annad has no subtype.
Finally each card has a release date, given in the format yyyy-mm-dd which gives the year, month and day in the ISO-8601 format.
Input
The input starts with a line containing a single positive integer $1 \leq n \leq 1\, 000$. Next there are $n$ lines, each with one card. That line contains the name, ID, type and release date of the card, separated by commas. If the type has a subtype it is given in the format type - subtype.
Finally there is a line with the words nafn, id, flokkur and dagsetning separated by spaces in some order. The cards should be sorted first by the first item on the line, then ties broken by the second item and so on. Here nafn means name, id is ID, flokkur is type and dagsetning is date.
Names are sorted alphabetically, IDs by ascending value, types in the order given above and dates in ascending chronological order. Here alphabetical order means by ASCII value, so spaces are first, then upper case letters and then lower case letters. This is the default order for strings in most programming languages.
Output
After the cards have been sorted into the right order, print the name of each card, in that order. Print one card name per line.
Scoring
Group |
Points |
Constraints |
1 |
5 |
$n = 1$. |
2 |
10 |
Cards are sorted by names first. |
3 |
15 |
Cards are sorted by ID first. |
4 |
20 |
Cards are sorted by type first, then ID. |
5 |
20 |
Cards are sorted by date first, then type, then name. |
6 |
30 |
No further constraints. |
Sample Input 1 | Sample Output 1 |
---|---|
7 Graedgiskrukka, 55144522, Galdur - Venjulegur, 2004-03-01 Afsaladur, 64631466, Skrimsli - Bodunar, 2004-10-12 Ojama toki, 00000000, Annad, 2017-07-01 Alvarlegur domur, 41420027, Gildra - Mot, 2004-12-01 OrlogsHETJA Demantagaur, 13093792, Skrimsli - Ahrifa, 2006-05-17 Sa bannadi, 33396948, Skrimsli - Ahrifa, 2004-10-12 Kvenharpiasystur, 12206212, Skrimsli - Ahrifa, 2004-10-12 nafn id flokkur dagsetning |
Afsaladur Alvarlegur domur Graedgiskrukka Kvenharpiasystur Ojama toki OrlogsHETJA Demantagaur Sa bannadi |
Sample Input 2 | Sample Output 2 |
---|---|
7 Graedgiskrukka, 55144522, Galdur - Venjulegur, 2004-03-01 Afsaladur, 64631466, Skrimsli - Bodunar, 2004-10-12 Ojama toki, 00000000, Annad, 2017-07-01 Alvarlegur domur, 41420027, Gildra - Mot, 2004-12-01 OrlogsHETJA Demantagaur, 13093792, Skrimsli - Ahrifa, 2006-05-17 Sa bannadi, 03396948, Skrimsli - Ahrifa, 2004-10-12 Kvenharpiasystur, 22206212, Skrimsli - Ahrifa, 2004-10-12 id nafn flokkur dagsetning |
Ojama toki Sa bannadi OrlogsHETJA Demantagaur Kvenharpiasystur Alvarlegur domur Graedgiskrukka Afsaladur |
Sample Input 3 | Sample Output 3 |
---|---|
7 Graedgiskrukka, 55144522, Galdur - Venjulegur, 2004-03-01 Afsaladur, 64631466, Skrimsli - Bodunar, 2004-10-12 Ojama toki, 00000000, Annad, 2017-07-01 Alvarlegur domur, 41420027, Gildra - Mot, 2004-12-01 OrlogsHETJA Demantagaur, 13093792, Skrimsli - Ahrifa, 2006-05-17 Sa bannadi, 33396948, Skrimsli - Ahrifa, 2004-10-12 Kvenharpiasystur, 12206212, Skrimsli - Ahrifa, 2004-10-12 flokkur id nafn dagsetning |
Kvenharpiasystur OrlogsHETJA Demantagaur Sa bannadi Afsaladur Graedgiskrukka Alvarlegur domur Ojama toki |
Sample Input 4 | Sample Output 4 |
---|---|
7 Graedgiskrukka, 55144522, Galdur - Venjulegur, 2004-03-01 Afsaladur, 64631466, Skrimsli - Bodunar, 2004-10-12 Ojama toki, 00000000, Annad, 2017-07-01 Alvarlegur domur, 41420027, Gildra - Mot, 2004-12-01 OrlogsHETJA Demantagaur, 13093792, Skrimsli - Ahrifa, 2006-05-17 Sa bannadi, 33396948, Skrimsli - Ahrifa, 2004-10-12 Kvenharpiasystur, 12206212, Skrimsli - Ahrifa, 2004-10-12 dagsetning flokkur nafn id |
Graedgiskrukka Kvenharpiasystur Sa bannadi Afsaladur Alvarlegur domur OrlogsHETJA Demantagaur Ojama toki |
Sample Input 5 | Sample Output 5 |
---|---|
7 Graedgiskrukka, 55144522, Galdur - Venjulegur, 2004-03-01 Afsaladur, 64631466, Skrimsli - Bodunar, 2004-10-12 Ojama toki, 00000000, Annad, 2017-07-01 Alvarlegur domur, 41420027, Gildra - Mot, 2004-12-01 OrlogsHETJA Demantagaur, 13093792, Skrimsli - Ahrifa, 2006-05-17 Sa bannadi, 33396948, Skrimsli - Ahrifa, 2004-10-12 Kvenharpiasystur, 12206212, Skrimsli - Ahrifa, 2004-10-12 flokkur dagsetning nafn id |
Kvenharpiasystur Sa bannadi OrlogsHETJA Demantagaur Afsaladur Graedgiskrukka Alvarlegur domur Ojama toki |