#2179. uva11163 Jaguar King

uva11163 Jaguar King

Description

image

Format

Input

The input file contains several sets of inputs. The total number of sets will be less than 50 . The description of each set is given below:

Each set starts with one integer N (4 ≤ N ≤ 40) which indicates the total number of jaguar warriors. You can assume that N is multiple of 4 . The next line will contain N numbers which indicates the final formation of the jaguars. Consecutive numbers will be separated by a single space.

The input will be terminated by the set where N = 0 . And this set should not be processed.

Output

For each set in the input, you should first print the set number starting from 1 . And the next line should be the minimum number of times the king has to jump to gain the new formation.

Check the sample input-output for more details. Output should be formatted like the sample output.

Samples

4
1 2 3 4
4
4 2 3 1
8
5 2 3 4 8 6 7 1
8
5 2 8 3 6 7 1 4
0
Set 1:
0
Set 2:
1
Set 3:
2
Set 4:
7

Limitation

此题数据偏弱,欢迎添加强力数据。