Snakes!

Write a program that reads a sequence of snakes, and prints them one after another.

Input

Input consists of a sequence of snake definitions, each one in a line. Each definitions starts with two natural numbers: cc is the column where starts the snake; nn is the number of times that changes of sense (from right to left or from left to right). After nn numbers come p1,,pnp_1, \dots, p_n indicating in which rows changes of sense. Finally, a natural rr comes indicating the row where has the eyes.

The rows and the columns start in 1. Assume that 0<p1<<pn<r0 < p_1 < \dots < p_n < r, and that the snake never goes out of the left side. Each snake starts moving to the right.

Output

Print the snakes as it is shown in the instance, separating them with a space.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:15:28.198Z

© Jutge.org, 2006–2026.
https://jutge.org