No, we don't luv stamina; we luv jumptrills!
After being tortured by three hours of handstream practice, the desperate XW is begging you to write a program that converts a given stream chart into a purely jumptrills chart.
Let's describe your task in formal terms. Note that some definitions in this problem may differ from those used in real 4-key rhythm games.
A chart is an $$$n \times 4$$$ binary matrix. Let $$$c_{i,j}$$$ denote the element in the $$$i$$$-th row and $$$j$$$-th column. Here, $$$c_{i,j} = 1$$$ means there is a note at that position, and $$$c_{i,j} = 0$$$ means it is empty. The given chart is guaranteed to satisfy that no column has two consecutive notes, i.e. for all $$$1 \lt i \leq n$$$ and $$$1 \leq j \leq 4$$$, we have $$$c_{i-1,j} \times c_{i,j} = 0$$$.
While playing the chart, you hit notes in columns 1 and 2 with your left hand, and notes in columns 3 and 4 with your right hand. To make the chart more playable, XW wants to ensure that no hand is required to hit notes in two consecutive rows. To achieve this, he needs you to perform the following operation:
After applying the above transformation, the chart will be converted from a terrifying dense handstream chart into a friendly jumptrills chart. But XW doesn't know how to implement it. Can you help him?
Reading the sample might help you better understand the task.
The first line contains a single integer $$$n$$$ $$$(1 \leq n \leq 10^3)$$$, denoting the number of rows in the chart.
The next $$$n$$$ lines each contain $$$4$$$ binary digits, denoting whether a note exists in each of the 4 columns of the $$$i$$$-th row.
It's guaranteed that no column has two consecutive '$$$1$$$'.
Output $$$n$$$ lines. Each line should contain $$$4$$$ binary digits denoting the modified chart. Do not output any extra spaces or blank lines.
41011010010010010
1011 0000 1100 0011
2000110100100100100100100001100001101001000011110000110100001111000011010010100001
0011 0000 1100 0011 0100 0000 1110 0000 0011 1100 0011 1100 0011 0100 0011 1100 0011 0000 1100 0011
For the first sample case:
In row $$$3$$$, both the left hand (column $$$1$$$) and the right hand (column $$$4$$$) are used. Since row $$$4$$$ had right-hand usage (column $$$3$$$), so the note in column $$$4$$$ is moved down to row $$$4$$$ .
In row $$$2$$$, the left hand (column $$$1$$$) is also used, so the note in column $$$1$$$ is moved down to row $$$3$$$ .
In row $$$1$$$, both hands are used again. But since no hand is used in row $$$2$$$ (Note that the original note in row $$$2$$$ has already been moved to row $$$3$$$), so the notes in row 1 weren't moved.
After these operations, no hand is used in two consecutive rows.