Contest Duration: - (local time) (300 minutes) Back to Home
G - Gold General Goes on the Grid /

Time Limit: 2 sec / Memory Limit: 1024 MB

### 注意

この問題に対する言及は、2020/6/6 18:00 JST まで禁止されています。言及がなされた場合、賠償が請求される可能性があります。 試験後に総合得点や認定級を公表するのは構いませんが、どの問題が解けたかなどの情報は発信しないようにお願いします。

• (x+1, y+1)
• (x, y+1)
• (x-1, y+1)
• (x+1, y)
• (x-1, y)
• (x, y-1)

### 制約

• 入力はすべて整数
• 1 \leq N \leq 800
• -200 \leq x_i, y_i, X, Y \leq 200
• (x_i, y_i) は相異なる。つまり、同じマスに 2 個以上の障害物はない。
• (0, 0) および (X, Y) には障害物はない
• (X, Y) \neq (0, 0)

### 入力

N X Y
x_1 y_1
:
x_N y_N


### 入力例 1

1 2 2
1 1


### 出力例 1

3


..G
.#.
S..


ここで、S はマス (0, 0) を、G はマス (X, Y) = (2, 2) を、# は障害物のあるマスを表します。

### 入力例 2

1 2 2
2 1


### 出力例 2

2


### 入力例 3

5 -2 3
1 1
-1 1
0 1
-2 1
-3 1


### 出力例 3

6


Score : 6 points

### Warning

Do not make any mention of this problem until June 6, 2020, 6:00 p.m. JST. In case of violation, compensation may be demanded. After the examination, you can reveal your total score and grade to others, but nothing more (for example, which problems you solved).

### Problem Statement

We have an infinite two-dimensional grid. Snuke is initially standing at the square (0,0) in this grid. There are N squares that contain an obstacle, and Snuke cannot enter those squares. The i-th obstacle is at the square (x_i, y_i). When Snuke is at the square (x, y), he can get to one of the following six squares in one move:

• (x+1, y+1)
• (x, y+1)
• (x-1, y+1)
• (x+1, y)
• (x-1, y)
• (x, y-1)

Print the minimum number of moves Snuke needs to reach the square (X, Y). If this square is unreachable, print -1.

### Constraints

• All values in input are integers.
• 1 \leq N \leq 800
• -200 \leq x_i, y_i, X, Y \leq 200
• The pairs (x_i, y_i) are distinct. That is, no square contains two or more obstacles.
• The squares (0, 0) and (X, Y) do not contain an obstacle.
• (X, Y) \neq (0, 0)

### Input

Input is given from Standard Input in the following format:

N X Y
x_1 y_1
:
x_N y_N


### Output

Print an integer as specified in Problem Statement.

### Sample Input 1

1 2 2
1 1


### Sample Output 1

3


Shown below is a part of the grid:

..G
.#.
S..


Here, S, G, and # stand for the square (0, 0), (X, Y) = (2, 2), and a square with an obstacle.

The minimum number of moves needed to reach (X, Y) = (2, 2) is three. One way to achieve it is (0, 0) \to (0, 1) \to (1, 2) \to (2, 2).

### Sample Input 2

1 2 2
2 1


### Sample Output 2

2


### Sample Input 3

5 -2 3
1 1
-1 1
0 1
-2 1
-3 1


### Sample Output 3

6