HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > M-KITs - 21!!! > problem:


1. 1_

M-KITs - 21!!!

Start: Apr.18.2021 at 03:00:00 PM
Finish: Apr.18.2021 at 05:00:00 PM
The contest is finished!
• Contest scoreboard

Contest problems

• 1. 1_
• 2. 2_
• 3. Служебные номера
• 4. Сезон дождей
• 5. 5_
• 6. 6_
• 7. 7_

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.

Santa Claus has come with a bag full of presents this year. A group of N kids stand in line, anxious to get their gifts. Santa Claus takes a present from his bag and gives it to the kid who is currently first in line. That kid then goes to the end of the line, unless he already has 4 gifts, in which case, he goes home. This process continues as long as there are presents in the bag and kids in the line.

You are given M gifts containing the presents in Santa's bag, in the order they are given away. Output the gifts each kid received.

Input
The first line will contain two numbers N and M (1 ≤ N ≤ 50, 1 ≤ M ≤ 50). Next M lines will contain gifts in the order they are given away. Each gift will contain between 1 and 10 lowercase letters ('a'-'z'), inclusive.
Output
Output should contain N lines exactly. i-th line should contain gifts description for i-th kid. i-th line starts with ki - number of gifts the i-th kid received (0, if no gifts). Next ki gifts follow in the order the kid received them, separated by spaces.

Input 1 Input 2 Input 3
3 4
ball
plane
robot
puzzle
5 3
ball
plane
robot
2 4
ball
ball
plane
plane
Output 1 Output 2 Output 3
2 ball puzzle
1 plane
1 robot
1 ball
1 plane
1 robot
0
0
2 ball plane
2 ball plane

Для отправки решений необходимо выполнить вход.

www.contester.ru