Information About Persons
The secret service of Landia decided to manage information about the whole people of Landia.
Unfortunately, its computer scientists are completely helpless. The input looks as follows.
The first line contains the number of records, n ≤ 200 000. On
the next n lines, every record stores information about one person:
-
personal code (a 31-bit positive integer);
-
status (two to seven nonspace characters); the first character is always
M
or F (sex); if the second character is – (minus), the person is
dead; otherwise, if one of the next characters is C, the person is computer
scientist; if one character is S, the person works for the secret service;
-
name of the person (8 to 35 characters, including space).
Why are the computer scientists of the secret service so helpless? The above list contains a
lot of duplicates: every time a person changes its status or name, the new record is simply
added at the end of the list.
The secret service wants to know:
-
how many men are living in Landia;
-
how many women are living in Landia;
-
how many computer scientists are working in Landia;
-
how many persons are working for the secret service;
-
the list of computer scientists who work for the secret service (in alphabetical order);
display this list after one empty line.
Beware: consider only the last (actual) status of every person.
Sample Input
1210 FAB Blue Mary15 MCA Sonk Jean10 FAS Rode Mary20 FXS Aske Vera20 F- Aske Vera12 FDE Kant Mia12 FSE Kant Mia16 MUV Barbe Louis21 MSC Conta Pietro24 FCS Ando Maria16 MCS Barbe Louis25 FET Donk Laura
download as text file
Output for Sample Input
3 men4 women4 computer scientists5 for secret service24 FCS Ando Maria16 MCS Barbe Louis21 MSC Conta Pietro
download as text file