#P6137. [IOI 2012] 理想城
[IOI 2012] 理想城
Description
Like many scientists and artists of his age, Little L is very interested in city planning and urban design. He is devoted to building an ideal city. The ideal city consists of blocks, and these blocks are placed on an infinite square grid. The cell in row and column is identified by the ordered pair . The cell is located at the upper-left corner of the grid. Given a cell , the adjacent cells (if they exist) are: , , , . Each block covers exactly one cell on the grid. A block can be placed on cell if and only if . We will use the coordinates of a cell to also denote the block on that cell. If two blocks are placed in adjacent cells, they are considered adjacent blocks. All blocks in the ideal city are connected, and there are no “holes” inside. In other words, all cells must satisfy the following two conditions:
- For any two empty cells, there exists at least one sequence of adjacent empty cells connecting them.
- For any two non-empty cells, there exists at least one sequence of adjacent non-empty cells connecting them.
The block placements in the following figures do not satisfy the conditions of an ideal city. The first two figures do not satisfy the first condition. The rd figure does not satisfy the second condition, and the th figure satisfies neither condition.

When traversing the ideal city, one step means moving from one block to an adjacent block. During a step, you cannot move into an empty cell. Suppose are the coordinates of the blocks. For any two different blocks and , their distance is the minimum number of steps needed to move from to .
The figure below shows an ideal city consisting of blocks. The block coordinates are:

Here, , , , and .
Given an ideal city, compute
Input Format
The first line contains a positive integer , the number of blocks in the ideal city.
Lines to each contain two non-negative integers. Line gives the coordinates of the -th block .
Output Format
Output a single line containing a positive integer, the value of . Since may be very large, you only need to output modulo .
11
2 5
2 6
3 3
3 6
4 3
4 4
4 5
4 6
5 3
5 4
5 6
174
Hint
For of the testdata, , and .
Translated by ChatGPT 5
京公网安备 11011102002149号