OpenKattis
Set #11

#### Start

2018-04-04 05:00 AKDT

## Set #11

#### End

2018-04-11 04:59 AKDT
The end is near!
Contest is over.
Not yet started.
Contest is starting in -1171 days 21:12:42

167:59:59

0:00:00

# Problem GThe Rectangles Are Surrounding Us!

You are given a list of rectangle boundaries. Each rectangle boundary is on integer coordinates. The rectangles surround squares on the coordinate grid. Your job is to determine the total number of such grid squares that are surrounded by all the rectangles.

## Input

Input consists of a set of $1$ to $10$ cases. Each case starts with the number of rectangles $0 < n \le 50$. Following this are $n$ rectangles, each given as four integers, $a$ $b$ $c$ $d$, where $a < c$ and $b < d$. The point $(a,b)$ defines the bottom left corner of the rectangle and the point $(c,d)$ defines the top right. All coordinates are between $0$ and $500$ (inclusive). Input ends when $n$ is $0$.

## Output

For each set of rectangles, print the total number of grid points they surround.

Sample Input 1 Sample Output 1
1
1 1 2 2
1
10 10 19 19
2
10 10 19 19
15 15 24 24
0

1
81
146