#include using namespace std; #include using namespace atcoder; #define ll long long int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, k; cin >> k >> n >> m; vector a(n, 0); for(int i = 0; i < k; i++){ int x; cin >> x; a[x - 1]++; } vector b(n); for(int i = 0; i < n; i++){ cin >> b[i]; } mcf_graph g(n + 2); int S = n; int T = n + 1; for(int i = 0; i < n; i++){ g.add_edge(S, i, a[i], 0); g.add_edge(i, T, b[i], 0); } for(int i = 0; i < m; i++){ int s, t, d; cin >> s>>t>>d; s--; t--; g.add_edge(s, t, k, d); g.add_edge(t, s, k, d); } pair f = g.flow(S, T, k); cout << f.second << endl; return 0; }