{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tA permutation on the integers from 1 to \u003cspan class\u003d\"MATH\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e is, simply put, a particular rearrangement of these integers. Your task is to generate a given permutation from the initial arrangement \u003cspan class\u003d\"MATH\"\u003e1, 2, 3,..., \u003ci\u003en\u003c/i\u003e\u003c/span\u003e using only two simple operations.\u003c/p\u003e\r\n\u003cul\u003e\r\n\t\u003cli\u003e\r\n\t\tOperation 1: You may swap the first two numbers. For example, this would change the arrangement 3,2,4,5,1 to 2,3,4,5,1.\u003c/li\u003e\r\n\t\u003cli\u003e\r\n\t\tOperation 2: You may move the first number to the end of the arrangement. For example, this would change the arrangement 3,2,4,5,1 to 2,4,5,1,3.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cdiv align\u003d\"CENTER\"\u003e\r\n\t\u003cimg align\u003d\"BOTTOM\" alt\u003d\"\\epsfbox{p11925.eps}\" border\u003d\"0\" height\u003d\"214\" src\u003d\"http://uva.onlinejudge.org/external/119/p11925.png\" width\u003d\"583\" /\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tThe input consists of a number of test cases. Each test case begins with a single integer \u003cspan class\u003d\"MATH\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e between 1 and 300. On the same line, a permutation of integers 1 through \u003cspan class\u003d\"MATH\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e is given where consecutive integers are separated by a single space.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tInput is terminated by a line containing `\u003ctt\u003e0\u003c/tt\u003e\u0026#39; which should not be processed.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tFor each test case you are to output a string on a single line that describes a sequence of operations. The string itself should consist only of the characters `\u003ctt\u003e1\u003c/tt\u003e\u0026#39; and `\u003ctt\u003e2\u003c/tt\u003e\u0026#39;. This string should be such that if we start with the initial arrangement \u003cspan class\u003d\"MATH\"\u003e1, 2, 3,..., \u003ci\u003en\u003c/i\u003e - 1, \u003ci\u003en\u003c/i\u003e\u003c/span\u003e and successively apply rules 1 and 2 according to the order they appear in the output, then the resulting permutation is identical to the input permutation.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tThe output string does not necessarily need to be the shortest such string, but it must be no longer than \u003cspan class\u003d\"MATH\"\u003e2\u003ci\u003en\u003c/i\u003e\u003csup\u003e2\u003c/sup\u003e\u003c/span\u003e characters. If it is possible to generate the permutation using 0 operations, then you may simply output a blank line.\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e3 2 1 3\r\n3 2 3 1\r\n4 4 2 3 1\r\n0\r\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e1\r\n2\r\n12122\r\n\u003c/pre\u003e"}}]}