#P5729. 【深基5.例7】工艺品制作

【深基5.例7】工艺品制作

Description

There is a solid glass cuboid with length, width, and height equal to w,x,hw, x, h. It can be considered as being made up of many 1×1×11\times1\times1 small cubes, and each small cube has coordinates (i,j,k)(i, j, k). Now we need to perform qq cuts. Each cut gives six parameters (x1,y1,z1),(x2,y2,z2)(x_1, y_1, z_1), (x_2, y_2, z_2), and it is guaranteed that x1x2x_1 \le x_2, y1y2y_1 \le y_2, z1z2z_1 \le z_2. During each cut, a laser tool is used to carve out a cuboid cavity whose faces are parallel to the faces of the original cuboid. The two diagonal corner points of the cavity are exactly the two points given in the parameters.

In other words, all small cubes (i,j,k)(i, j, k) satisfying x1ix2x_1 \le i \le x_2, y1jy2y_1 \le j \le y_2, z1kz2z_1 \le k \le z_2 will be evaporated by the laser. For example, for a 4×4×44\times4\times4 large cube with volume 6464, if the parameters are (1,1,1),(2,2,2)(1, 1, 1), (2, 2, 2), then the 88 small cubes in the middle will be evaporated, leaving 5656 small cubes. Now, after all cutting operations, how many unit cubes of volume remain in the craft?

Input Format

The first line contains three positive integers w,x,hw, x, h.

The second line contains one positive integer qq.

The next qq lines each contain six integers (x1,y1,z1),(x2,y2,z2)(x_1, y_1, z_1), (x_2, y_2, z_2).

Output Format

Output one integer representing the answer.

4 4 4
1
1 1 1 2 2 2

56

Hint

Constraints: 1w,x,h201 \le w, x, h \le 20, 1q1001 \le q \le 100. 1x1x2w1 \le x_1 \le x_2 \le w, 1y1y2x1 \le y_1 \le y_2 \le x, 1z1z2h1 \le z_1 \le z_2 \le h.

Translated by ChatGPT 5