Rectangles

No attempts yetTime limit1sMemory limit128 MB

Problem

There are nn rectangles drawn on the plane. Every rectangle has sides parallel to the coordinate axes, and all of its vertices have integer coordinates. A block is defined as follows.

  • Each rectangle is a block by itself.
  • If two distinct blocks have a common segment, they merge into one new block. If they have no common segment, the two blocks are considered separate.

Here, two rectangles 'have a common segment' when the region in which they overlap contains a segment of positive length. Concretely, two rectangles belong to the same block if they share part of an edge or overlap over an area of positive size. Conversely, if two rectangles meet only at a single point (a corner) or do not meet at all, they belong to different blocks.

The rectangles in the first figure below form two separate blocks.

The rectangles in the second figure below form a single block.

Given the number of rectangles and the coordinates of their vertices on standard input, write a program that finds the number of separate blocks formed by the rectangles and writes it to standard output.

Input

The first line contains the number of rectangles nn (1n70001 \le n \le 7000). Each of the next nn lines describes one rectangle with four integers: the xx and yy coordinates of its bottom-left vertex, followed by the xx and yy coordinates of its top-right vertex. All coordinates are non-negative integers not greater than 1000010000.

Output

Print a single integer: the number of separate blocks formed by the given rectangles.