An N-digit runaround number is characterized as follows: • It is an integer with exactly N digits, each of which is between 1 and 9, inclusively. • The digits form a sequence with each digit telling where the next digit in the sequence occurs. This is done by giving the number of digits to the right of the digit where the next digit in the sequence occurs. If necessary, counting wraps around from the rightmost digit back to the leftmost. • The leftmost digit in the number is the first digit in the sequence, and the sequence must return to this digit after all digits in the number have been used exactly once. • No digit will appear more than once in the number. For example, consider the number 81362. To verify that this is a runaround number, we use the steps shown below:
2/2 Sample Output Case 1: 13 Case 2: 147 Case 3: 1263 Case 4: 81236 Case 5: 83491 Case 6: 83491 Case 7: 913425 Case 8: 8124956