Page not loading? Try clicking here.
Placeholder

#1671

Square Paper 2 1s 3MB

Problems

You have a white square paper of size 100 × 100.

On this paper, you can attach black square papers of size 10 × 10 so that the sides of the black papers are parallel to the sides of the white paper.

After attaching one or more black papers, write a program to calculate the perimeter of the total black area.

For example, if four black papers are attached on the white paper as shown in <Figure 1>, the total black perimeter would be 96.


Input

The first line contains the number of black papers.

Each of the following lines contains the position of a black paper, given as two natural numbers:

  1. The distance from the left edge of the white paper to the left edge of the black paper.

  2. The distance from the bottom edge of the white paper to the bottom edge of the black paper.

Constraints:

  • The number of black papers does not exceed 100.

  • The positions of the black papers are integers between 1 and 90 inclusive.

  • Black papers do not extend outside the white paper.


Output

Print a single line containing the perimeter of the total black area.


Example

4 

3 7
5 2
15 7
13 14
96


Source

KOI 본선 2007 중2

You must sign in to write code.