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<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define H 510
struct Ver{
    ll y,x,t;
    Ver(ll y,ll x,ll t){
	this->y=y,this->x=x,this->t=t;
    }
    bool operator<(const Ver&key)const{return 0;}
    bool operator>(const Ver&key)const{return 0;}
    bool operator==(const Ver&key)const{
	return this->y==key.y&&this->x==key.x&&this->t==key.t;
    }
    bool operator!=(const Ver&key)const{
	return !(this->operator==(key));
    }
    struct Hash{
	ll operator()(const Ver&key)const{
	    return key.t*H*H+key.y*H+key.x;
	}
    };
};
#define N 100010
ll h,w,a,b,c,n,s[N],t[N];
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
ll dis[H][H];
unordered_map<Ver,ll,Ver::Hash> d;
void Dijkstra(Ver s){
    typedef pair<ll,Ver> P;
    priority_queue<P,vector<P>,greater<P> >Q;
    Q.push(make_pair(0,s));
    while(!Q.empty()){
	ll cost=Q.top().first;
	Ver key=Q.top().second;
	Q.pop();
	ll i=key.y,j=key.x,t=key.t;
	if(i<0||i==h||j<0||j==w)continue;
	if(d.find(key)!=d.end())continue;
	d[key]=cost;
	lol(r,4){
	    int xx=j+dx[r],yy=i+dy[r];
	    if(t==4){
		Q.push(make_pair(cost+b,Ver(i,j,r)));
		Q.push(make_pair(cost+c,Ver(yy,xx,4)));
	    }
	    if(t==r){
		Q.push(make_pair(cost+dis[i][j]*c,Ver(i,j,4)));
		Q.push(make_pair(cost+a,Ver(yy,xx,r)));
	    }
	}
    }
}
void BFS(){
    lol(i,h)lol(j,w)dis[i][j]=mod;
    queue<Ver> Q;
    lol(i,n)Q.push(Ver(s[i],t[i],0));
    while(!Q.empty()){
	Ver key=Q.front();
	Q.pop();
	ll y=key.y,x=key.x,t=key.t;
	if(dis[y][x]<=t)continue;
	dis[y][x]=t;
	lol(r,4){
	    int xx=x+dx[r],yy=y+dy[r];
	    if(xx<0||xx==w||yy<0||yy==h)continue;
	    Q.push(Ver(yy,xx,t+1));
	}
    }
}
int main(){
    cin>>h>>w>>a>>b>>c>>n;h++,w++;
    lol(i,n)scanf("%lld%lld",&s[i],&t[i]);BFS();
    Dijkstra(Ver(s[0],t[0],4));
    cout<<d[Ver(s[n-1],t[n-1],4)]<<endl;
    return 0;
}