
| Contests | Virtual Contests | Problems | Submit | Runs Status | Rank List | Forum |
You have been contacted by Zing Zhu to calculate, given the height the tide will reach and the position and height of all fence strips, the total area of land which will not be flooded during the high tide. You may assume that the widths of fence strips are so thin compared to the size of the land that, for the purpose of calculating the total area, fence strips may be considered as having widths equal to zero.

Input
The input contains several test cases. The first line of a test case contains an integer N indicating the number of fence strips in the island (1 ≤ N ≤ 2000). Each of the next N lines contains five integers X1, Y1, X2, Y2 and H, representing respectively the start point of the strip (X1, Y1), the end point of the strip (X2, Y2) and the strip height (H). The last line of a test case contains an integer W representing the tide height. Coordinates are given in meters, heights in centimeters. Furthermore, X1 = X2 or Y1 = Y2 (but not both); -500 ≤ X1, Y1, X2, Y2 ≤ 500; and 1 ≤ W, H ≤ 1000. The end of input is indicated by N = 0.
Output
For each test case in the input your program must produce one line of output, containing one integer representing the total area (in m2) of the land which will not be flooded.
Sample Input
4
-20 20 20 20 200
20 20 20 -20 200
0 0 0 20 100
-10 0 20 0 200
100
4
-20 20 20 20 200
20 20 20 -20 200
0 0 0 20 100
-10 0 20 0 200
101
0
Output for the Sample Input
400
0