#include using namespace std; int main(){ int N, M; cin >> N >> M; vector> E(N); for (int i = 0; i < M; i++){ int u, v; cin >> u >> v; u--; v--; E[u].push_back(v); E[v].push_back(u); } vector R(N); for (int i = 0; i < N; i++){ cin >> R[i]; } vector B(N); for (int i = 0; i < N; i++){ cin >> B[i]; } long long sum = 0; for (int i = 0; i < N; i++){ sum += max(R[i], B[i]); } long long ans = 0; for (int i = 0; i < 2; i++){ for (int j = 0; j < N; j++){ vector> d(2, vector(N, -1)); priority_queue, vector>, greater>> pq; pq.push(make_tuple(0, i, j)); while (!pq.empty()){ long long c = get<0>(pq.top()); int t = get<1>(pq.top()); int v = get<2>(pq.top()); pq.pop(); if (d[t][v] == -1){ d[t][v] = c; for (int w : E[v]){ if (d[1 - t][w] == -1){ if (t == 0){ pq.push(make_tuple(c + max(R[v], B[v]) - R[v], 1 - t, w)); } if (t == 1){ pq.push(make_tuple(c + max(R[v], B[v]) - B[v], 1 - t, w)); } } } } } if (d[1 - i][j] != -1){ ans = max(ans, sum - d[1 - i][j]); } } } if (ans != 0){ cout << ans << endl; } else { vector c(N, -1); c[0] = 0; queue Q; Q.push(0); while (!Q.empty()){ int v = Q.front(); Q.pop(); for (int w : E[v]){ if (c[w] == -1){ c[w] = 1 - c[v]; Q.push(w); } } } long long ans1 = 0, ans2 = 0; for (int i = 0; i < N; i++){ if (c[i] == 0){ ans1 += R[i]; ans2 += B[i]; } if (c[i] == 1){ ans1 += B[i]; ans2 += R[i]; } } cout << max(ans1, ans2) << endl; } }