eolymp
bolt
Try our new interface for solving problems
Problems

Rectangles-3

Rectangles-3

Time limit 2 seconds
Memory limit 64 MiB

Long ago in a three-dimensional space-lived fared rectangles. These were highly moral, duhovnoobogaschennye and symmetrical creatures. However, in their hearts they were flat and rectangular. And the corners, as we know, there are sharp. In general, the quarrel became rectangles. Thousands have lasted centuries, domestic conflicts over division of territory. Each rectangle quarreled with all the other boxes, with whom he had shared at least one point in space (highly spiritual beings are not material and may overlap in space). Rectangles are feuding, even if for only one point. By some intelligible only to these creatures causes a quadrilateral, each rectangle is located in space parallel to one of the coordinate plane and its edges are parallel to the axes. But here's a solution the problem of strife! Savvy figures appealed for help to you. To resolve the conflicts they must calculate how many pairs of conflicting rectangles is in habitable space.

Input data

In the first line of the input file contains the number n (1n100000) - the number of rectangles. Followed by n lines containing descriptions of each rectangle. Each description consists of six integers - the coordinates of two opposite corners of the rectangle. All coordinates - the integers from 1 to 999.

Output data

Display the number of conflicting pairs of rectangles.

Examples

Input example #1
3
1 1 1 1 3 3
1 3 3 1 6 6
1 4 4 1 5 5
Output example #1
2