提示: 欢迎访问OurACM平台。
Problem 1515 Balloons in a Box

Accept: 297    Submit: 1741
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

You must write a program that simulates placing spherical balloons into a rectangular box.

The simulation scenario is as follows. Imagine that you are given a rectangular box and a set of points inside the box. Each point represents a position where you might place a balloon. To place a balloon at a point, center it at the point and inflate the balloon until it touches a side of the box or a previously placed balloon. You may use the points in any order you like, and need not use every point. Your objective is to place balloons in the box in an order that maximizes the total volume occupied by the balloons.

You are required to calculate the volume within the box that is not enclosed by the balloons.

All integer will be in [-1000, 1000].

Input

The input consists of several test cases. The first line of each test case contains a single integer n that indicates the number of points in the set (n ≤ 6). The second line contains three integers that represent the (x, y, z) integer coordinates of a corner of the box, and the third line contains the (x, y, z) integer coordinates of the opposite corner of the box. The next n lines of the test case contain three integers each, representing the (x, y, z) coordinates of the points in the set. The box has non-zero length in each dimension and its sides are parallel to the coordinate axes.

Output

For each test case print one line which indicates the volume of the box not occupied by balloons. Round the volume to the nearest integer.

Sample Input

2 0 0 0 10 10 10 3 3 3 7 7 7

Sample Output

774

Source

FZU 2007 ICPC Qualification Round I

Submit  Back  Status  Discuss