# Include <cstdio> // EK () Algorithm . Time complexity (VE ^ 2) # include <queue> # include <cstring> using namespace STD; const int maxn = 100; const int INF = (1 <30)-1; int G [maxn] [maxn]; int flow [maxn], pre [maxn]; bool vis [maxn]; int n, m; int BFS (int s, int e) {memset (PRE,-1, sizeof (pre); memset (VIS, false, sizeof (VIS); queue <int> q; vis [s] = true; for (INT I = 1; I <= N; I ++) flow [I] = inf; q. push (s); While (! Q. empty () {int now = Q. front (); q. pop (); If (now = N) break; For (INT I = 1; I <= N; I ++) {// search for the shortest traffic if (! Vis [I] & G [now] [I]> 0) {vis [I] = true; flow [I] = min (flow [now], G [now] [I]); Pre [I] = now; q. push (I) ;}} if (! Vis [e] | E = 1) // The Return-1; else return flow [E];} int EK (int s, int e) {int temp, D, res, maxflow; maxflow = 0; while (D = BFS (S, E ))! =-1) {maxflow + = D; temp = N; while (temp! = 1) {res = pre [temp]; G [res] [temp]-= D; // forward edge G [temp] [res] + = D; // reverse side temp = res;} return maxflow;} int main () {int T, CA = 1; int start, end, capacity; scanf ("% d ", & T); While (t --) {memset (G, 0, sizeof (g); scanf ("% d", & N, & M ); for (INT I = 1; I <= m; I ++) {scanf ("% d", & START, & End, & capacity ); G [start] [end] + = capacity;} printf ("case % d: % d \ n", CA ++, EK (1, N ));} return 0 ;}