Problem 7
Problem 7
Yonas
The Cheeky-Cheeky is a new song. They dance it in Mula, and also in Hong Kong. All
the freekies dance it, and the geek all love it. And the Cheeky-Cheeky is danced like
this:
1. The breikin-brokin.
2. The meneito.
3. The roboqueitor.
4. The maiquel-guolkin.
In this problem you have to learn to dance the Cheeky-Cheeky. This dancing consists of
4 basic steps (as listed above) that are arranged into a particular sequence. Then this
sequence can be repeated an arbitrary number of times.
For example, if the sequence is ‘123’, then the Cheeky-Cheeky is danced like this:
‘12312312312312...’. But if the sequence is ‘123124’, then the steps of the dancing are
‘123124123124123...’.
You are given some of the steps of a particular dancing. Those steps will contain
between 2 (inclusive) and 3 (not inclusive) times the basic sequence. You have to
continue the dancing.
For example, if the basic sequence is ‘123’, we can have the following possibilities:
Input Output
123123 12312312…
1231231 23123123...
123412312 31231231...
Input
The first line of the input contains an integer indicating the number of test cases. Each
case contains some of the first steps of a dancing. It is a single line with a list of digits
(1, 2, 3 or 4) with no spaces between them. It will not have more than 2000 steps.
Remember that the case contains the basic sequence twice, and possibly has some
more steps (but not thrice).
Output
For each test case, the output should contain the 8 following steps of the dancing,
followed by three dots ‘...’.