Comfortable Cows#11210

Comfortable Cows

1 second
128 megabytes
Hard

Farmer Nhoj's pasture can be regarded as a large 2D grid of square "cells" (picture a huge chessboard). Initially, the pasture is empty.

Farmer Nhoj will add cows to the pasture one by one. The -th cow will occupy a cell (x_i, y_i) that is distinct from the cells occupied by all other cows.

A cow is said to be "comfortable" if it is horizontally or vertically adjacent to exactly three other cows. Unfortunately, cows that are too comfortable tend to lag in their milk production, so Farmer Nhoj wants to add additional cows until no cow (including the ones that he adds) is comfortable. Note that the added cows do not necessarily need to have and coordinates in the range .

For each in the range , output the minimum number of cows Farmer Nhoj would need to add until no cows are comfortable if initially, the pasture started with only cows .

Input

The first line contains a single integer (1 \le n \le 10^5). Each of the next lines contains two integers, indicating the (, ) (0 \le x, y \le 1000) coordinates of a cow's cell.

Output

Print the minimum number of cows Farmer Nhoj needs to add for each in , on separate lines.

Examples

Example 1

Loading
Loading

Note

For i = 4, Farmer Nhoj must add an additional cow at (, ) to make the cow at (, ) uncomfortable.

For i = 9, the best Farmer Nhoj can do is place additional cows at (, ), (, ), (, ) and (, ).