Dyson Box
题号:NC221185
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

A Dyson Sphere is a hypothetical megastructure that completely encompasses a star and captures a large percentage of its power output. The concept is a thought experiment that attempts to explain how a spacefaring civilization would meet its energy requirements once those requirements exceed what can be generated from the home planet's resources alone. Only a tiny fraction of a star's energy emissions reach the surface of any orbiting planet. Building structures encircling a star would enable a civilization to harvest far more energy.

One day, Moca has another idea for a thought experiment. Assume there is a special box called Dyson Box. The gravitational field in this box is unstable. The direction of the gravity inside the box can not be determined until it is opened.

The inside of the box can be formed as a 2-dimensional grid, while the bottom left corner's coordinate is (0, 0) and the upper right corner's coordinate is . There will be n events. In the i-th event, a new cube will appear, whose upper right corner's coordinate is (x_i, y_i) and bottom left corner's coordinate is (x_i - 1, y_i - 1).

There are two directions of gravity in the box, vertical and horizontal. Suppose Moca opens the box after the i-th event. In that case, she has  probability of seeing the direction of the gravity inside the box is vertical, and the other  probability is horizontal. And then, she will measure the total length of the outline of all the cubes. If the direction of gravity is horizontal, all the cubes inside will move horizontally to the left under its influence. Similarly, vertical gravity will cause all the cubes to move downward.

Moca hates probability, so that she is asking for your help. If you have known the coordinates of all the cubes in chronological order, can you calculate the total length of these two cases after each event?

输入描述:

The first line contains one integer n  -- the number of cubes.

Each of the following n lines describes a cube with two integers x_i, y_i .

It is guaranteed that no two cubes have the same coordinates.

输出描述:

For each of the n cubes, print one line containing two integers -- two answers when the the direction of gravity is vertical and horizontal.
示例1

输入

复制
4
1 2
3 2
2 1
4 1

输出

复制
4 4
8 6
8 8
10 8

说明

In the only example, the inside of the box is as below, and the bold lines mark the outline of all the cubes.

After the 1-st event:

After the 2-nd event:

After the 3-rd event:

After the 4-th event: