Special Billiards

Time Limit: 5 Seconds    Memory Limit: 32768 KB

WishingBone is playing a special kind of billiards. There are one White-ball and 8 Colored-ball marked 1,2,3,4,5,6,7,8 on a slick table. The size of the table is 300cm*150cm, and the semidiameter of the ball is 3cm. In initial situation, positions of the 9 balls are uncertain. But balls will never be overlapped with others or out of the table. There are only four holes on the table, each corner has one. (Centres of holes:(0,0), (300,0), (0,150), (300,150))

Give you some knowledge of billiards: If you want to knock a Colored-ball into a hole with the White-ball, assume that the centres of hole,Colored-ball,White-ball are called A,B,C, then you should prolong AB with diameter of the ball to C'. So, C' is the target of the White-ball, that's to say you should aim the White-ball from C to C' and then fire! (See the figure 1)


figure 1. hint of the billiards


But, consider some situations, if the angle <CC'A is a sharp angle or a right angle, or if there are other balls on the way of the White-ball or the Colored-ball, then you can't knock this Colored-ball into the appointed hole. (See the figure 2)


figure 2. green line indicates legal path, while red one indicates the illegal or impossible path.


The above-mentioned things are usual, but the rules are special:

1. Two players hit once each by turns.

2. If it's your turn now, you must knock a Colored-ball into a hole follow the showed hint above. (Assume there is no miss) So, in figure 2, you could find that you must hit one of these balls marked 1,5(shoot to up-left hole),6,7, but can't hit 2,3(3 to holes are blocked by 2 and 7, White-ball to 2 is blocked by 3).

3. If there is no ball to pocket, the game is over. Notice this! Not only no ball left on the table is called game-over, but also include this situation: several balls left, but all of the goal way be blocked or not obtuse angle.

4. After you knocked a Colored-ball in, the White-ball should be put on the place where the Colored-ball used to be.

5. The score you got relies to the marked number on the ball. So, if you holed out the 5th ball, you got 5 points.

6. You can't try to hole out one Colored-ball by knocking another Colored-ball.

7. The method like reflect by the side of the table and so on are not allowed, you can only use the method mentioned above.

Note: To simplify the problem, ignore that White-ball will touch other balls after it knocked its target.

WishingBone and his opponent are both so clever. Assume that each player always chooses the play that leads to the best possible outcome for himself/herself. And assume WishingBone always plays first. Give you the initial position of the 9 balls, can you calculate the maximal score difference (defined as WishingBone's score minus Opponent's) WishingBone could get?

Input

Input consists of several test cases. Each case will contain 9 lines. And each line contains 2 positive integer x, y. (3<=x<=297, 3<=y<=147) Denote the initial positions of the balls' centre, the first line shows the White-ball, the second shows the ball marked 1, the third shows the ball marked 2, and so on.

Output

Output the maximal difference WishingBone could get. Each case per line.

Sample Input

41 92
97 40
161 142
192 105
232 62
62 68
115 69
160 50
25 35

Sample Output

6
Submit

Source: ZOJ Monthly, January 2005