#3335. uva11163 Jaguar King

内存限制:128 MiB 时间限制:1 Sec

题目描述

输入格式

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.

输出格式

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.

样例

样例输入


			
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

数据范围与提示

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