CSES - KILO 2017 3/5 - Bored Uolevi
  • Time limit: 2.00 s
  • Memory limit: 512 MB

Uolevi likes doodling a lot. When he is bored he draws meaningless straight line segments on his calculation paper.

Uolevi's calculation paper is special: it can be imagined as a plane with cartesian coordinate system with range [0, 2000] \times [0, 2000] for coordinates. The grid lines are all lines of the form x = c or y = c for every integer c between 0 and 2000, inclusive. Therefore, the grid contains 2000 \times 2000 squares.

Now, Uolevi wonders how many grid squares are crossed by at least one of the lines he drew. Please help Uolevi to find the answer. Note that touching an edge of a grid square is not considered as crossing this square.

Input

The first line of input contains integer n denoting the number of lines Uolevi drew. The i-th line of following n lines contains four integers, x_{i1}, y_{i1}, x_{i2}, y_{i2}, denoting that the i-th segment Uolevi drew is a straight line segment between points (x_{i1}, y_{i1}) and (x_{i2}, y_{i2}).

Output

Output how many grid squares are crossed by at least one of the line segments Uolevi drew.

Constraints

  • 1 \le n \le 2000
  • 0 \le x_{i1}, y_{i1}, x_{i2}, y_{i2} \le 2000
  • the lengths of all line segments in input are non-zero

Examples

Input:

3
0 0 5 5
0 5 5 0
0 5 5 0

Output:

9

Input:

1
0 0 4 3

Output:

6

Input:

2
0 0 4 3
1 0 3 3

Output:

6