using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program{ const int mod=(int)1e9+7; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; var h=new long[s[0]][]; for(int i = 0;i[] li; private Dictionary[] h; private bool[] b; private int[] l; private long ans; private int n,go; private const int inf=int.MaxValue; public Mfp(int n){ this.n=n; li=new List[n]; h=new Dictionary[n+1]; for(int i=0;i(); h[i]=new Dictionary(); } } public void Edge(int a,int b,long c){ if(a==b){return;} if(!h[a].ContainsKey(b)){ li[a].Add(b); li[b].Add(a); h[a].Add(b,c); h[b].Add(a,0); } else{h[a][b]+=c;} } public long Dinic(int st,int go){ this.go=st; ans=0; long z=1; while(z>0){ l=new int[n]; var qu=new Queue>(); qu.Enqueue(Tuple.Create(st,1)); l[st]=1; while(qu.Count>0){ var e=qu.Dequeue(); for(int i=0;iu;i++){ if(!b[li[a][i]]&&l[li[a][i]]0){ b=new bool[n]; z=Fu2(st,inf); ans+=z; } return ans; } private long Fu2(int a,long p){ if(a==go){return p;} long u=0; b[a]=true; for(int i=0;iu;i++){ if(!b[li[a][i]]&&h[a][li[a][i]]!=0){ long z=Fu2(li[a][i],Min(p-u,h[a][li[a][i]])); h[a][li[a][i]]-=z; h[li[a][i]][a]+=z; u+=z; } } if(u!=0){b[a]=false;} return u; } public void Vc(int s,Action f){ b=new bool[n]; Fu4(s,0,f); for(int i=0;i f){ b[a]=true; if((p&1)==0&&p!=0){f(a);} for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i