#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>n>>c>>w; using T = tuple; vector > G(n); { vector s(w),t(w),y(w),m(w); for(Int i=0;i>s[i]; for(Int i=0;i>t[i]; for(Int i=0;i>y[i]; for(Int i=0;i>m[i]; for(Int i=0;i > dp(n,vector(c+1,INF)); priority_queue, greater > pq; dp[0][0]=0; pq.emplace(dp[0][0],0,0); while(!pq.empty()){ Int v,x,d; tie(d,v,x)=pq.top();pq.pop(); //cout<c) continue; if(dp[u][nx]>nd){ dp[u][nx]=nd; pq.emplace(dp[u][nx],u,nx); } } } Int ans=INF; for(Int x=0;x<=c;x++) chmin(ans,dp[n-1][x]); if(ans>=INF) ans=-1; cout<