#include using namespace std; #define rep(i, x, limit) for (long long i = (long long)x; i < (long long)limit; i++) #define REP(i, x, limit) for (long long i = (long long)x; i <= (long long)limit; i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define el '\n' #define spa " " #define Yes cout << "Yes" << el #define No cout << "No" << el #define YES cout << "YES" << el #define NO cout << "NO" << el #define inp(x) for(auto &i:x)cin>>i #define eps (1e-10) #define Equals(a,b) (fabs((a) - (b)) < eps ) #define debug(x) cerr << #x << " = " << x << el using ll = long long; using ull = unsigned long long; using i128 = __int128_t; using pii = pair; using pll = pair; using vi = vector; using vl = vector; using vvl = vector>; using vs = vector; using vb = vector; const double pi = 3.141592653589793238; const int inf = 1073741823; const ll infl = 1LL << 60; const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const string abc = "abcdefghijklmnopqrstuvwxyz"; const ll MOD = 998244353; #include using namespace atcoder; using mint = modint998244353; using vm = vector; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n,r,c; cin>>n>>r>>c; vl X(n),Y(n),Z(n),S(n); inp(X); inp(Y); inp(Z); inp(S); /* 状態 0 : 免許なし 1 : AT 2 : MT 3 : 船舶 4 : 船舶 + AT 5 : 船舶 + MT 頂点 i + n*k = 地点i、状態k hub 6*n : 船舶 6*n + 1 : 船舶 + AT 6*n + 2 : 船舶 + MT */ ll sz=n*6+3; vector> G(sz); // 道路 rep(i,0,r){ ll u,v,w,a,m; cin>>u>>v>>w>>a>>m; u--; v--; ll ca=min(w,a); ll cm=min({w,a,m}); vl cost={ w, // 免許なし ca, // AT cm, // MT w, // 船舶 ca, // 船舶 + AT cm // 船舶 + MT }; rep(j,0,6){ ll U=u+n*j; ll V=v+n*j; G[U].push_back({V,cost[j]}); G[V].push_back({U,cost[j]}); } } rep(i,0,n){ // AT免許取得 G[i].push_back({i+n,X[i]}); G[i+n*3].push_back({i+n*4,X[i]}); // MT免許取得 G[i].push_back({i+n*2,Y[i]}); G[i+n].push_back({i+n*2,Y[i]}); G[i+n*3].push_back({i+n*5,Y[i]}); G[i+n*4].push_back({i+n*5,Y[i]}); // 船舶免許取得 G[i].push_back({i+n*3,Z[i]}); G[i+n].push_back({i+n*4,Z[i]}); G[i+n*2].push_back({i+n*5,Z[i]}); // 船 rep(j,0,3){ ll v=i+n*(j+3); ll hub=n*6+j; // i -> hub G[v].push_back({hub,S[i]+c}); // hub -> i G[hub].push_back({v,S[i]}); } } // Dijkstra vl dist(sz,infl); priority_queue< pll, vector, greater > pq; dist[0]=0; pq.push({0,0}); while(!pq.empty()){ auto [d,v]=pq.top(); pq.pop(); if(dist[v]d+cost){ dist[to]=d+cost; pq.push({dist[to],to}); } } } // 地点Nに到着すれば免許状態は何でもよい ll ans=infl; rep(j,0,6){ ans=min(ans,dist[n-1+n*j]); } cout<