#include using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 10000000000000 template struct Dinic{ struct edge{ int to; T weight; int ind; }; vector> E; T inf; Dinic(vector>> &e,T iv = 1000000001){ inf = iv; E.resize(e.size(),vector()); for(int i=0;i dis(E.size(),-1); queue Q; Q.push(s); dis[s] = 0; while(Q.size()!=0){ int u = Q.front(); Q.pop(); for(int i=0;i it(E.size(),0); while(true){ T F = dfs(s,t,inf,it,dis); if(F==0)break; ret+=F; } } return ret; } T dfs(int now,int t,T f,vector &it,vector &dis){ if(now==t)return f; for(int &i=it[now];i>N>>M; long long d; cin>>d; vector>> E(N,vector>()); for(int i=0;i>u>>v>>p>>q>>w; u--;v--; E[u].push_back({p,q,v,w}); } vector num(N,0); for(int i=1;i>> E2(M+2,vector>()); for(int i=0;i D(E2,Inf); cout<