inline ll read(){ ll x=0, f=1; char ch=getchar(); while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();} return x*f; }
#define N 210 #define M 5010 #define INF 0x3f3f3f3f #define v e[i].to #define w e[i].val int n, m, s, t, t1, t2, t3; ll max_flow; int head[N], tot, vis[N]; structedge {int to, nxt, val;} e[M<<1];
voidadd_edge(int x, int y, int z){ e[tot]={y, head[x], z}, head[x]=tot++; }
intdfs(int u, int minf){ if (u==t||minf==0) return minf; vis[u]=1; for (int i=head[u]; i!=-1; i=e[i].nxt) { if (w==0||vis[v]) continue; int f=dfs(v, min(minf, w)); if (f<=0) continue; e[i].val-=f, e[i^1].val+=f; return f; } return0; }
voidFF(){ max_flow=0; while (1) { memset(vis, 0, sizeof(vis)); int f=dfs(s, INF); if (f==0) return; max_flow+=f; } }
inline ll read(){ ll x=0, f=1; char ch=getchar(); while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();} return x*f; }
#define N 210 #define M 5010 #define INF 0x3f3f3f3f #define v e[i].to #define w e[i].val int n, m, s, t, t1, t2, t3; ll max_flow; int head[N], tot, vis[N], pre[N], flow[N]; structedge {int to, nxt, val;} e[M<<1];
voidadd_edge(int x, int y, int z){ e[tot]={y, head[x], z}, head[x]=tot++; }
intbfs(){ memset(vis, 0, sizeof(vis)); memset(pre, 0, sizeof(pre)); queue<int> q; q.push(s); vis[s]=1, flow[s]=INF; while (!q.empty()) { int u=q.front(); q.pop(); for (int i=head[u]; i!=-1; i=e[i].nxt) { if (w==0||vis[v]) continue; flow[v]=min(flow[u], w); vis[v]=1, pre[v]=i, q.push(v); if (v==t) return flow[v]; } } return0; }
voidEK(){ int f=0; while (f=bfs()) { for (int u=t, i; u!=s; u=e[i^1].to) { i=pre[u], e[i].val-=f, e[i^1].val+=f; } max_flow+=f; } }
inline ll read(){ ll x=0, f=1; char ch=getchar(); while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();} return x*f; }
#define N 210 #define M 5010 #define INF 0x3f3f3f3f #define v e[i].to #define w e[i].val int n, m, s, t; int t1, t2, t3; ll max_flow; int head[N], cur[N], tot; int d[N], vis[N];
structedge { int to, nxt, val; } e[M<<1];
voidadd_edge(int x, int y, int z){ e[tot]={y, head[x], z}, head[x]=tot++; }
boolbfs(){ memset(d, -1, sizeof(d)); queue<int> q; q.push(s), d[s]=0; while (!q.empty()) { int u=q.front(); q.pop(); for (int i=head[u]; i!=-1; i=e[i].nxt) { if (w==0||d[v]!=-1) continue; d[v]=d[u]+1, q.push(v); } } return d[t]!=-1; }
intdfs(int u, int minf){ if (u==t||minf==0) return minf; int f, flow=0; for (int i=cur[u]; i!=-1; i=e[i].nxt) { cur[u]=i; if (d[v]!=d[u]+1||!(f=dfs(v, min(minf, w)))) continue; minf-=f, flow+=f; e[i].val-=f, e[i^1].val+=f; if (minf==0) return flow; } return flow; }
voidDinic(){ max_flow=0; while (bfs()) { for (int i=1; i<=n; ++i) cur[i]=head[i]; max_flow+=dfs(s, INF); } }