#include using namespace std; namespace mxfl{ const int N=100, M=1e4; typedef int str; const str inf=1e9; struct E{ int to; str fl; int nex; }e[M]; int n, hea[N], cne, cur[N], st, en, d[N]; void init(int n_=N-1){ n=n_; cne=1; memset(hea,0,sizeof (int)*(n+1)); } void adde(int u,int v,str w,str bw=0){ e[++cne]=(E){v,w,hea[u]}; hea[u]=cne; e[++cne]=(E){u,bw,hea[v]}; hea[v]=cne; } bool bfs(){ memset(d,33,sizeof d); d[st]=0; queueq; q.push(st); for (int x,y,z;!q.empty();){ x=q.front(); q.pop(); if (x==en) return 1; for (int i=hea[x];i;i=e[i].nex){ if (!e[i].fl) continue; y=e[i].to; z=d[x]+1; if (z>w&1){ mxfl::adde(w+bas,S,f[S]); } } for (int S=1;S<(1<>T;T--;){ cin>>n>>m>>k; for (int i=0;i>a[i]>>b[i]>>c[i]; int tot=0; for (int i=0;i>1; if (chk(mid)){ r=mid-1; ans=mid; }else{ l=mid+1; } } cout<