402655: GYM100834 D Polycarp and the Table

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Polycarp and the Tabletime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Polycarp decided to help to organize the Contest and create logins for each team. He has got a table consisting of N + 1 rows and M columns in the CSV format. It means that the table looks like a text which consists of N + 1 lines. Each line i is written as "ai, 1;ai, 2;... ;ai, m" (without quotations), where ai, j — cell content at the intersection of the row i and the column j. Each cell content corresponds to the line 1 to 30 signs long. A cell can contain only small and capital Latin letters and digits. The first line contains the names of the columns. They always contain "Team", "City", "Email", "Organization", "Participant1", "Participant2" and "Participant3" — team name, city, email address, organization name and participant name respectivly. Columns can be arranged in any order.

Polycarp has to make one more table in the same format including the table fields "Team", "Login", "Email", "Participants" — team name, login, email address and participants respectivly. The login looks like "team<XXX> (<Organization>, <City>)", where <XXX> — three-figure number of the team in the origina table, Organization and City — organization and city names respectivly. The participants complete it as follows: "<Participant1>,<Participant2>,<Participant3>" — participants’ names comma separated.

Input

The table looks like a table consisting of N + 1rows and M columns. 1 ≤ N ≤ 100, 1 ≤ M ≤ 15. The format of data is given in the statement.

Output

The table consists of N + 1 rows in the format given in the statement.

ExamplesInput
Country;Organization;City;Team;Email;
Participant1;Participant2;
Participant3$
Russia;KFU;Kazan;KFU01;team01;P1;P2;
P3$
Russia;KFU;Kazan;KFU02;team02;P4;P5;
P6$
Russia;KFU;Kazan;KFU03;team03;P7;P8;
P9$
Russia;ITMO;SaintPetersburg;ITMO00;
somefakemail;I1;I2;I3$
Output
Team;Login;Email;Participants$
KFU01;team001 (KFU, Kazan);team01;
P1,P2,P3$
KFU02;team002 (KFU, Kazan);team02;
P4,P5,P6$
KFU03;team003 (KFU, Kazan);team03;
P7,P8,P9$
ITMO00;team004 (ITMO, SaintPetersburg);
somefakemail;I1,I2,I3$
Note

Line breaks in the example are marked using $, due text does not fit in the page.

加入题单

上一题 下一题 算法标签: