Box intersection volume

Compute the volume shared by N axis-aligned boxes by intersecting their x, y, and z ranges.

Easy1MathInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

There are NN boxes in three dimensional space. Each box is given by two opposite corners, and every face is parallel to a coordinate plane.

Write a program that computes the volume of the region covered by all NN boxes at once, that is, the volume of their intersection.

Input

The first line contains the number of boxes NN (1N10001 \le N \le 1000).

Each of the next NN lines contains six integers x1x_1, y1y_1, z1z_1, x2x_2, y2y_2, z2z_2 separated by spaces. The first three are the coordinates of one corner and the last three are the coordinates of the opposite corner. All coordinates are between 11 and 10001000, and x1<x2x_1 < x_2, y1<y2y_1 < y_2, z1<z2z_1 < z_2.

Output

Print the volume of the intersection of the NN boxes on the first line. If the intersection is empty or has no thickness, print 00.