P1456 Monkey King

Description

Once in a forest, there lived N aggressive monkeys. At the beginning, they each does things in its own way and none of them knows each other. But monkeys can't avoid quarrelling, and it only happens between two monkeys who does not know each other. And when it happens, both the two monkeys will invite the strongest friend of them, and duel. Of course, after the duel, the two monkeys and all of their friends will know each other, and the quarrel above will no longer happen among these monkeys even if they have ever conflicted. Assume that every money has a strongness value, which will be reduced to only half of the original after a duel(that is, 10 will be reduced to 5 and 5 will be reduced to 2). And we also assume that every monkey knows himself. That is, when he is the strongest one in all of his friends, he himself will go to duel.

Input Format

There are several test cases, and each case consists of two parts. First part: The first line contains an integer N(N

Output Format

For each of the conflict, output -1 if the two monkeys know each other, otherwise output the strength value of the strongest monkey among all of its friends after the duel.

Explanation/Hint

题目可能有多组数据 题目来源 ZOJ 3rd Anniversary Contest