Invalid Crashout


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C++, Java, Python

After crashing out from the first AllUni competitive programming competition, Maged's team decided to launch some nukes at Adelaide. Now, all that remains of Adelaide are a collection of walls, running either North-South or East-West. To rebuild the city, we need to do is figure how many "valid rooms" are left among the rubble.

A valid room is a collection of 4 walls that form a rectangle, and valid rooms can overlap each other. For example, there are 4 valid rooms in the below diagram:

Help find all the valid rooms among the rubble!

Input

The first line contains an integer n (1 \leq n \leq 200), the number of walls left in Adelaide.

The next n lines contain x_1, y_1, x_2, and y_2 (0 \leq x, y \leq 10^9), representing the start and end points of the wall. Either x_1 = x_2 or y_1 = y_2, but never both.

Output

Output the number of "valid rooms" left in the rubble of Adelaide.

Clarifications

  • Walls can be repeated, or lie completely inside each other.
  • Two walls that overlap along the same line should be merged and considered a single wall.
  • Although the coordinate system in this problem doesn't matter, the images show right being +x and up being +y.

Example

Input 1
5
1 1 1 5
3 1 3 5
0 2 4 2
0 4 4 4
0 5 4 5
Output 1
3

This test case looks like:

Input 2
6
0 0 0 10
0 10 10 10
10 10 10 20
10 20 20 20
20 20 20 0
20 0 0 0
Output 2
0

This test case looks like:


Comments

There are no comments at the moment.