Evacuation#4370

Evacuation

2 seconds
128 megabytes
Medium

Dramatic events are unfolding: an old spider was resting on its rectangular web when suddenly, parts of it caught fire. Fortunately, the spider had prepared a special cell for evacuation. Now, it must reach this cell by taking the safest path possible.

The web is a rectangular grid ranging from to . The locations where the fire starts are known. The spider begins at and needs to reach the evacuation point at . The spider moves along the grid edges, taking second per move, while the fire spreads every seconds. The spider cannot occupy a vertex that is on fire.

Let's define the concept of path danger. For any given path, a vertex is considered dangerous if, at the time the spider passes through it, at least one adjacent vertex is on fire. The danger of a path is the total number of dangerous vertices along it. The spider aims to minimize this danger for its safety. Can you help it find the safest path?

Input

The first line contains the integers and (1 \leq a, b \leq 500) representing the dimensions of the web. The second line contains the integer (1 \leq t \leq 100), which is the time interval for the fire to spread. The third line contains the integer (1 \leq k \leq a \cdot b), representing the number of ignition points. The following lines each contain two integers, indicating the coordinates of the vertices that are on fire.

Output

Output the minimum danger level of the path from to . If no such path exists, output "-1".

Examples

Example

Input
4 3
2
1
2 1
Output
3

Example

Input
4 3
1
1
2 1
Output
-1

Example 1

Loading
Loading

Note

In the first example, the spider follows the path (1, 1) \rightarrow (1, 2) \rightarrow (1, 3) \rightarrow (2, 3) \rightarrow (3, 3) \rightarrow (4, 3). Initially, is dangerous because the adjacent cell is on fire. At , only is burning, so is safe. When the spider reaches , additional cells catch fire, but none are adjacent to , making it safe. At , the adjacent cell is on fire, making dangerous. At , more cells catch fire, including , making dangerous. Finally, at , no new cells catch fire, and none of the burning ones are adjacent, so it is safe. The path danger is , with dangerous vertices at , , and . No other path avoids burning cells.

In the second example, after three seconds, catches fire, preventing the spider from reaching it in time.