Rectangles-3#1481

Rectangles-3

2 seconds
64 megabytes
Hard

Long ago in a three-dimensional space lived rectangles. These were highly moral, spiritually enriched, and symmetrical creatures. However, in their essence, they were flat and rectangular. As we know, corners can be sharp, so the rectangles started to quarrel. Household conflicts over the division of territory lasted for thousands of years. Each rectangle quarreled with all other rectangles with which it shared at least one point in space (these highly spiritual beings are non-material and may overlap in space). Rectangles feud even if they touch at only one point. For some reason known only to these quadrilaterals, each rectangle is oriented in space parallel to one of the coordinate planes, with its sides parallel to the coordinate axes.

Input

The first line of the input file contains the integer (1 \leq n \leq 100000) — the number of rectangles. The following lines each describe one rectangle. Each description consists of six integers — the coordinates of two opposite corners of the rectangle. All coordinates are integers between and , inclusive.

Output

Output the number of pairs of conflicting rectangles.

Examples

Example 1

Loading
Loading