{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"Given a string of characters, we can permute the individual characters to make new strings. At first we order the string into alphabetical order. Then we start permuting it.\n\nFor example the string **\u0027abba\u0027** gives rise to the following 6 distinct permutations in alphabetical order:\n\n1. **aabb**\n2. **abab**\n3. **abba**\n4. **baab**\n5. **baba**\n6. **bbaa**\n\nGiven a string, you have to find the **n\u003csup\u003eth\u003c/sup\u003e** permutation for that string. For the above case **\u0027aabb\u0027** is the 1\u003csup\u003est\u003c/sup\u003e and **\u0027baab\u0027** is the 4\u003csup\u003eth\u003c/sup\u003e permutation."}},{"title":"Input","value":{"format":"MD","content":"Input starts with an integer **T (\u0026le; 200)**, denoting the number of test cases.\n\nEach case contains a non empty string of lowercase letters with length no more than **20** and an integer **n (0 \u0026lt; n \u0026lt; 2\u003csup\u003e31\u003c/sup\u003e)**."}},{"title":"Output","value":{"format":"MD","content":"For each case, output the case number and the **n\u003csup\u003eth\u003c/sup\u003e** permutation. If the **n\u003csup\u003eth\u003c/sup\u003e** permutation doesn\u0027t exist print `Impossible`."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\naabb 1\naabb 6\naabb 7\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: aabb\nCase 2: bbaa\nCase 3: Impossible\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}