There is an infinite square grid. Some vertices of the grid are black and other vertices are white.
A vertex is called inner if it is both vertical-inner and horizontal-inner. A vertex is horizontal-inner if there are two black vertices in the same row such that is between them. Similarly, a vertex is vertical-inner if there are two black vertices in the same column such that is between them.
On each step, all white inner vertices become black, while black vertices keep their color. The process stops when all inner vertices are black.
Write a program that determines the number of black vertices on the grid after the process stops.
The first line contains an integer (0 \leq n \leq 100000) — the number of black vertices.
The next lines contain the coordinates of the black vertices. The coordinates do not exceed 10^9 by absolute value.
Print the number of black vertices after the process stops. If the process never stops, output -1.

Esempio 1