Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

binary search

data structures

dfs and similar

graphs

shortest paths

*1900

No tag edit access

The problem statement has recently been changed. View the changes.

×
D. Nearest Excluded Points

time limit per test

4 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given $$$n$$$ distinct points on a plane. The coordinates of the $$$i$$$-th point are $$$(x_i, y_i)$$$.

For each point $$$i$$$, find the nearest (in terms of Manhattan distance) point with integer coordinates that is not among the given $$$n$$$ points. If there are multiple such points — you can choose any of them.

The Manhattan distance between two points $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$ is $$$|x_1 - x_2| + |y_1 - y_2|$$$.

Input

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of points in the set.

The next $$$n$$$ lines describe points. The $$$i$$$-th of them contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le 2 \cdot 10^5$$$) — coordinates of the $$$i$$$-th point.

It is guaranteed that all points in the input are distinct.

Output

Print $$$n$$$ lines. In the $$$i$$$-th line, print the point with integer coordinates that is not among the given $$$n$$$ points and is the nearest (in terms of Manhattan distance) to the $$$i$$$-th point from the input.

Output coordinates should be in range $$$[-10^6; 10^6]$$$. It can be shown that any optimal answer meets these constraints.

If there are several answers, you can print any of them.

Examples

Input

6 2 2 1 2 2 1 3 2 2 3 5 5

Output

1 1 1 1 2 0 3 1 2 4 5 4

Input

8 4 4 2 4 2 2 2 3 1 4 4 2 1 3 3 3

Output

4 3 2 5 2 1 2 5 1 5 4 1 1 2 3 2

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/13/2024 15:48:19 (l2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|