{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\"text/css\"\u003e\r\nh1,h2,h3,h4,h5,h6{margin-bottom:0;}div.textBG p{margin: 0 0 0.0001pt;}\u003c/style\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u003cimg align\u003d\"right\" hspace\u003d\"20\" src\u003d\"http://uva.onlinejudge.org/external/109/p10935.jpg\" vspace\u003d\"20\" /\u003eGiven is an ordered deck of \u003cem\u003en\u003c/em\u003e cards numbered 1 to \u003cem\u003en\u003c/em\u003e with card 1 at the top and card \u003cem\u003en\u003c/em\u003e at the bottom. The following operation is performed as long as there are at least two cards in the deck:\u003c/p\u003e\r\n\u003cp style\u003d\"margin:20px\"\u003e\r\n\tThrow away the top card and move the card that is now on the top of the deck to the bottom of the deck.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tYour task is to find the sequence of discarded cards and the last, remaining card.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tEach line of input (except the last) contains a number \u003cem\u003en\u003c/em\u003e\u0026nbsp;\u0026le;\u0026nbsp;50. The last line contains 0 and this line should not be processed. For each number from the input produce two lines of output. The first line presents the sequence of discarded cards, the second line reports the last remaining card. No line will have leading or trailing spaces. See the sample for the expected format.\u003c/p\u003e\r\n\u003ch3\u003e\r\n\tSample input\u003c/h3\u003e\r\n\u003cpre\u003e\r\n7\r\n19\r\n10\r\n6\r\n0\r\n\u003c/pre\u003e\r\n\u003ch3\u003e\r\n\tOutput for sample input\u003c/h3\u003e\r\n\u003cpre\u003e\r\nDiscarded cards: 1, 3, 5, 7, 4, 2\r\nRemaining card: 6\r\nDiscarded cards: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 4, 8, 12, 16, 2, 10, 18, 14\r\nRemaining card: 6\r\nDiscarded cards: 1, 3, 5, 7, 9, 2, 6, 10, 8\r\nRemaining card: 4\r\nDiscarded cards: 1, 3, 5, 2, 6\r\nRemaining card: 4\r\n\u003c/pre\u003e\r\n\u003chr /\u003e\r\n\u003cp\u003e\r\n\t\u003cem\u003eFolklore, adapted by Piotr Rudnicki\u003c/em\u003e\u003c/p\u003e"}}]}