Ian is in his FIT2004 class, and wants to ask the TA for help to solve a 6767-dimensional dynamic programming problem.

The classroom can be modelled as an n×mn \times m rectangle, with the bottom left located at (1,1)(1, 1), and the top right located at (n,m)(n, m). Note that coordinates along the edge of the rectangle are inside the classroom.

Unfortunately there are kk chairs blocking his way, located at distinct coordinates.

Ian, from any coordinate (c1,c2)(c_1, c_2), can move to any adjacent coordinate inside the classroom:

  • (c1+1,c2)(c_1 + 1, c_2)
  • (c1−1,c2)(c_1 - 1, c_2)
  • (c1,c2+1)(c_1, c_2 + 1)
  • (c1,c2−1)(c_1, c_2 - 1)

When moving, Ian has a set of specific interactions:

  • Step from the ground onto the top of the chair, which requires 11 unit of energy.

  • Step from a chair onto the ground, which requires 11 unit of energy.

  • Step from a chair onto a chair, which does not require energy.

  • Step from the ground onto the ground, which does not require energy.

All interactions take 11 second of time.

Ian is currently at position (a,b)(a, b), and the TA is located at position (c,d)(c, d).

Since Ian values his time and energy, he would like to know the minimum energy he must use to reach the TA in at most tt seconds.

Input

The first line contains n,mn, m.

The next line contains a,b,c,d,k,ta, b, c, d, k, t.

The next kk lines each contain (xi,yi)(x_i, y_i), the coordinates of the ii-th chair.

Output

Output a single number, the minimum energy that Ian must use to move from (a,b)(a, b) to (c,d)(c, d) in at most tt seconds, or −1-1 if Ian cannot reach the TA in time.

Constraints

  • 3≤n⋅m≤1033 \le n \cdot m \le 10^3

  • 1≤a,c≤n1 \le a, c \le n

  • 1≤b,d≤m1 \le b, d \le m

  • 0≤k≤n⋅m−20 \le k \le n \cdot m - 2

  • (xi,yi)≠(a,b)(x_i, y_i) \neq (a, b)

  • (xi,yi)≠(c,d)(x_i, y_i) \neq (c, d)

  • (xi,yi)(x_i, y_i) are distinct

  • 1≤t≤1041 \le t \le 10^4

Example 1

Input 1
3 3
1 1 3 3 3 5
1 2
2 2
3 2
Output 1
2
Explanation

Ian can take the path (1,1)→(2,1)→(2,2)→(2,3)→(3,3)(1, 1) \to (2, 1) \to (2, 2) \to (2, 3) \to (3, 3).

Moving from (2,1)→(2,2)(2, 1) \to (2, 2) requires stepping from the ground onto a chair, which uses 11 energy.

Moving from (2,2)→(2,3)(2, 2) \to (2, 3) requires stepping from a chair onto the ground, which uses 11 energy.

In total, Ian uses 1+1=21 + 1 = 2 energy, and reaches the TA within 55 seconds.

It can be shown that this path minimises Ian's energy usage.

Example 2

Input 2
3 3
1 1 1 3 2 6
1 2
2 2
Output 2
0

Example 3

Input 3
3 3
1 1 3 3 7 4
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output 3
2

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.