#include using namespace std; #include "atcoder/mincostflow" using namespace atcoder; int main(void){ int k,n,m; cin >> k >> n >> m; mcf_graph g(n+2); vector a(k); for(int i=0;i> a[i]; g.add_edge(0,a[i],1,0); } vector b(n); for(int i=0;i> b[i]; g.add_edge(i+1,n+1,b[i],0); } vector u(m); vector v(m); vector d(m); for(int i=0;i> u[i] >> v[i] >> d[i]; g.add_edge(u[i],v[i],1e9,d[i]); g.add_edge(v[i],u[i],1e9,d[i]); } cout << g.flow(0,n+1).second << endl; return 0; }