#D4229. Move on Ice

    ID: 3517 Type: Default 5000ms 536MiB

Move on Ice

Move on Ice

Problem

The penguins Fluoro is in an infinitely wide ice cube (sx sx , sy sy ). There is a hole in the trout (tx tx , ty ty ) through which water can enter. There are n n lumps of ice on the ice, each in the square (xi x_i , yi y_i ).

Fluoro can move up, down, left and right in four directions. It's slippery on the ice, so when you move it keeps moving until it hits a block of ice. When it hits a lump of ice, it stops just before the square with the lump of ice. You can enter the hole by passing through the square of the hole.

Fluoro can stop in the middle by stepping on it only once.

It hurts when it hits a lump of ice, so I want to reduce the number of hits as much as possible. Find the minimum number of hits before moving to a square with a hole (tx tx , ty ty ). If you can't reach it, print - 1.

Constraints

The input satisfies the following conditions.

  • 0 leqn leq105 0 \ leq n \ leq 10 ^ 5
  • 0 leqsx 0 \ leq sx , sy sy , tx tx , ty ty , xi x_i , yi leq109 y_i \ leq 10 ^ 9
  • All given coordinates are different

Input

The input is given in the following format.

sx sx sy sy tx tx ty ty n n x1 x_1 y1 y_1 ... xn x_n yn y_n

All inputs are given as integers. The coordinates of the cell where Fluoro is on the first line are given separated by blanks. The coordinates of the cells with holes in the second line are given separated by blanks. The third line gives the number of ice cubes n n . The coordinates of the square with the ice block on the following n n line are given, separated by blanks.

Output

Output the minimum number of hits before moving to a hole. If you can't reach it, print - 1.

Examples

Input

0 0 13 33 2 0 34 14 0

Output

0

Input

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

Output

4

Input

0 0 0 2 1 0 1

Output

-1

inputFormat

input satisfies the following conditions.

  • 0 leqn leq105 0 \ leq n \ leq 10 ^ 5
  • 0 leqsx 0 \ leq sx , sy sy , tx tx , ty ty , xi x_i , yi leq109 y_i \ leq 10 ^ 9
  • All given coordinates are different

Input

The input is given in the following format.

sx sx sy sy tx tx ty ty n n x1 x_1 y1 y_1 ... xn x_n yn y_n

All inputs are given as integers. The coordinates of the cell where Fluoro is on the first line are given separated by blanks. The coordinates of the cells with holes in the second line are given separated by blanks. The third line gives the number of ice cubes n n . The coordinates of the square with the ice block on the following n n line are given, separated by blanks.

outputFormat

Output

Output the minimum number of hits before moving to a hole. If you can't reach it, print - 1.

Examples

Input

0 0 13 33 2 0 34 14 0

Output

0

Input

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

Output

4

Input

0 0 0 2 1 0 1

Output

-1

样例

0 0
0 2
1
0 1
-1