#include #include #include #include using namespace atcoder; using namespace std; using ll = long long; #define REP(i, n) for(ll i=0; i<(n);i++) int main() { ll k, n, m; cin >> k >> n >> m; mcf_graph mcf(n + 2); REP(i, k) { ll a; cin >> a; mcf.add_edge(n, a - 1, 1, 0); } REP(i, n) { ll b; cin >> b; mcf.add_edge(i, n + 1, b, 0); } REP(i, m) { ll u, v, d; cin >> u >> v >> d; u--; v--; mcf.add_edge(u, v, 1e9, d); mcf.add_edge(v, u, 1e9, d); } auto ans = mcf.flow(n, n+1, k); assert(ans.first==k); cout << ans.second << endl; return 0; }