Square Count

Time limit1sMemory limit128 MB

Problem

On the floor of each room of a museum, the tiles form a grid of unit squares. Besides the individual $1 \times 1$ tiles, larger squares can be formed: any $k \times k$ block of tiles ($2 \times 2$, $3 \times 3$, and so on) is also a square, and every such square must be added to the count. A square may also lie across two rooms, passing from one into an adjacent room through the opening between them.

For example, the two rooms of the first sample below contain 86 squares in total: 45 of size $1 \times 1$, 28 of size $2 \times 2$, and 13 of size $3 \times 3$. (The opening between those two rooms is only 3 squares wide.)

Given the rooms of the museum, count all of the squares.

Input

The input consists of multiple test cases. The first line of each test case is a positive integer $n \le 1000$, the number of rooms in that test case. Each of the next $n$ lines describes one room. Every room is a rectangle, given as

x1 y1 x2 y2

where $(x_1, y_1)$ and $(x_2, y_2)$ are the integer coordinates of two opposite corners. No two rooms overlap, although they may share a side. If a shared side has length $m > 2$, then a door of length $m - 2$ exists between the two rooms, centered along the shared side, and a square may pass from one room into the other only through such a door. No square of any size overlaps more than two rooms. All $x$ and $y$ values are at most 1,000,000. A line containing $n = 0$ ends the input and is not processed.

Output

For each test case, output one line in the form Case i: t, where $i$ is the test case number (starting from 1) and $t$ is the total number of squares. Every answer fits in a 32-bit integer.