Problem: You are a manager of a prestigious soccer team in the JOI league.

The team has $N$ players numbered from 1 to $N$. The players are practicing hard in order to win the tournament game. The field is a rectangle whose height is $H$ meters and width is $W$ meters. The vertical line of the field is in the north-south direction, and the horizontal line of the field is in the east-west direction. A point in the field is denoted by ($i, j$) if it is $i$-meters to the south and $j$ meters to the east from the northwest corner of the field.

After the practice finishes, players must clear the ball. In the beginning of the clearance, the player $i$ ($1 \leq i \leq N$) stands at ($S_i, T_i$). There is only one ball in the field, and the player 1 has it. You stand at ($S_N, T_N$) with the player $N$. The clearance is finished if the ball is passed to ($S_N, T_N$), and you catch it. You cannot move during the clearance process.

You can ask players to act. But, if a player acts, his fatigue degree will be increased according to the action. Here is a list of possible actions of the players. If a player has the ball, he can act (i),(ii), or (iii). Otherwise, he can act (ii) or (iv).

* (i) Choose one of the 4 directions (east/west/south/north), and choose a positive integer $p$. Kick the ball to that direction. Then, the ball moves exactly p meters. The kicker does not move by this action, and he loses the ball. His fatigue degree is increased by $A \times p + B$.
* (ii) Choose one of the 4 directions (east/west/south/north), and move 1 meter to that direction. If he has the ball, he moves with it. His fatigue degree is increased by $C$ regardless of whether he has the ball or not.
* (iii) Place the ball where he stands. He loses the ball. His fatigue degree does not change.
* (iv) Take the ball. His fatigue degree does not change. A player can take this action only if he stands at the same place as the ball, and nobody has the ball.



Note that it is possible for a player or a ball to leave the field. More than one players can stand at the same place.

Since the players just finished the practice, their fatigue degrees must not be increased too much. You want to calculate the minimum possible value of the sum of fatigue degrees of the players for the clearance process.





Example

Input

6 5
1 3 6
3
1 1
0 4
6 5


Output

26

Solution (in CPP):

Solution:
#include <cstdio>
#include <queue>
#include <algorithm>
#define X_MAX 500
#define Y_MAX 500
#define N_MAX 100000
#define V_MAX ((X_MAX + 1) * (Y_MAX + 1))
#define lld "%lld"
typedef long long lnt;
typedef bool bnt;
typedef void vnt;
const lnt LNF = 0x3F3F3F3F3F3F3FLL;
const int dx[] = {-1, 0, +1, 0}, dy[] = {0, -1, 0, +1};
int X, Y, N, i, k, x, y, u, v, sx, sy, tx, ty, Ql = -1, Qr = -1, Q[V_MAX * 2];
lnt A, B, C, dir[X_MAX + 1][Y_MAX + 1], dis[X_MAX + 1][Y_MAX + 1][3];
inline bnt chk(int x, int y) { return x >= 0 && x <= X && y >= 0 && y <= Y; }
struct dat
{
	int k, x, y; lnt d;
	bnt operator < (const dat & p) const { return d > p.d; }
} p;
std::priority_queue<dat> P;
int main()
{
	scanf("%d %d" lld lld lld "%d", &X, &Y, &A, &B, &C, &N);
	for (x = 0; x <= X; ++x)
		for (y = 0; y <= Y; ++y)
			dir[x][y] = -1;
	scanf("%d %d", &sx, &sy), dir[sx][sy] = 0;
	for (i = 2; i < N; ++i)
		scanf("%d %d", &x, &y), dir[x][y] = 0;
	scanf("%d %d", &tx, &ty), dir[tx][ty] = 0;
	for (x = 0; x <= X; ++x)
		for (y = 0; y <= Y; ++y)
			if (!dir[x][y])
				Q[++Qr] = x, Q[++Qr] = y;
	while (Ql < Qr)
	{
		x = Q[++Ql], y = Q[++Ql];
		for (k = 0; k < 4; ++k)
			if (chk(u = x + dx[k], v = y + dy[k]) && !~dir[u][v])
				dir[u][v] = dir[x][y] + C, Q[++Qr] = u, Q[++Qr] = v;
	}
	for (k = 0; k < 3; ++k)
		for (x = 0; x <= X; ++x)
			for (y = 0; y <= Y; ++y)
				dis[x][y][k] = LNF;
	P.push((dat) {2, sx, sy, 0});
	while (true)
	{
		p = P.top(), P.pop();
		if (dis[p.x][p.y][p.k] < LNF)
			continue;
		if (p.x == tx && p.y == ty)
			break;
		dis[p.x][p.y][p.k] = p.d;
		switch (p.k)
		{
		case 2:
			for (k = 0; k < 2; ++k)
				if (dis[p.x][p.y][k] == LNF)
					P.push((dat) {k, p.x, p.y, p.d + B});
			for (k = 0; k < 4; ++k)
				if (chk(u = p.x + dx[k], v = p.y + dy[k]) && dis[u][v][2] == LNF)
					P.push((dat) {p.k, u, v, p.d + C});
			break;
		default:
			if (dis[p.x][p.y][2] == LNF)
				P.push((dat) {2, p.x, p.y, p.d + dir[p.x][p.y]});
			for (k = p.k; k < 4; k += 2)
				if (chk(u = p.x + dx[k], v = p.y + dy[k]) && dis[u][v][p.k] == LNF)
					P.push((dat) {p.k, u, v, p.d + A});
		}
	}
	printf(lld "\n", p.d);
	return 0;
}