Problem A
Number Line Artwork

Otto the octopus loves to make number line artworks.
Whenever Otto makes an artwork, he first places each of his
-
moving an arm leftwards to the next mark, or
-
moving an arm rightwards to the next mark, or
-
making a new mark.
When Otto makes a new mark, he always makes the mark exactly
halfway between two existing marks. More specifically, if Otto
uses his
Given the colors of the first
Input
The first line contains two integers,
Thereafter follows
You may assume colors are always written in lowercase, and that there never will be a sequence of moves such that an arm moves “out of range” of the marks. You may also assume that the following constraints are met:
-
-
For each action,
and
Output
Output a single line with the colors of the final artwork in order from left to right. Each color should be separated with a single space.
Sample Input 1 | Sample Output 1 |
---|---|
3 5 red blue green 0 R 0 R 0 gold 1 black 2 purple |
red black blue gold purple green |
Sample Input 2 | Sample Output 2 |
---|---|
2 6 a b 0 R 0 b 1 L 1 a 0 R 0 c |
a a b c b |