Output #1
2 4 5
At first, the pieces are on Squares $1$, $3$, and $4$. The operations are performed against them as follows:
* The $3$\-rd piece from the left is on Square $4$. This is not the rightmost square, and the next square on the right does not contain a piece, so move the $3$\-rd piece from the left to Square $5$. Now, the pieces are on Squares $1$, $3$, and $5$.
* The $3$\-rd piece from the left is on Square $5$. This is the rightmost square, so do nothing. The pieces are still on Squares $1$, $3$, and $5$.
* The $1$\-st piece from the left is on Square $1$. This is not the rightmost square, and the next square on the right does not contain a piece, so move the $1$\-st piece from the left to Square $2$. Now, the pieces are on Squares $2$, $3$, and $5$.
* The $1$\-st piece from the left is on Square $2$. This is not the rightmost square, but the next square on the right (Square $3$) contains a piece, so do nothing. The pieces are still on Squares $2$, $3$, and $5$.
* The $2$\-nd piece from the left is on Square $3$. This is not the rightmost square, and the next square on the right does not contain a piece, so move the $2$\-nd piece from the left to Square $4$; Now, the pieces are still on Squares $2$, $4$, and $5$.
Thus, after the $Q$ operations have ended, the pieces are on Squares $2$, $4$, and $5$, so $2$, $4$, and $5$ should be printed in this order, with spaces in between.