#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N,R; ll C,S; vector> E[303030][4]; ll X[303030],Y[303030],Z[303030]; ll dp[30303][3][2]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>R>>C; FOR(i,N) cin>>X[i]; FOR(i,N) cin>>Y[i]; FOR(i,N) cin>>Z[i]; FOR(i,N) { cin>>S; E[i][3].push_back({N,S}); E[N][3].push_back({i,S+C}); } FOR(i,N+1) { FOR(x,3) FOR(y,2) dp[i][x][y]=1LL<<60; } FOR(i,R) { cin>>x>>y>>j>>k>>l; k=min(k,j); l=min(k,l); x--,y--; E[x][0].push_back({y,j}); E[y][0].push_back({x,j}); E[x][1].push_back({y,k}); E[y][1].push_back({x,k}); E[x][2].push_back({y,l}); E[y][2].push_back({x,l}); } dp[0][0][0]=0; priority_queue> Q; Q.push({0,0}); while(Q.size()) { ll co=-Q.top().first; int cur=Q.top().second/6; int l1=Q.top().second%6/2; int l2=Q.top().second%2; Q.pop(); if(dp[cur][l1][l2]!=co) continue; if(cur==N-1) { cout<