#include using namespace std; typedef long long ll; int MAX = 100010; vector dp0(MAX, 0), dp1(MAX, 0), a(MAX), b(MAX); vector> adj(MAX); void dfs(int i, int p) { dp0[i] += a[i]; for (int j : adj[i]) { if (j == p) continue; dfs(j, i); dp0[i] += max(dp0[j], dp1[j]); dp1[i] += max(dp0[j], dp1[j] + b[i] + b[j]); } return; } int main() { int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) cin >> b[i]; for (int i = 0; i < n-1; ++i) { int u, v; cin >> u >> v; u--; v--; adj[u].push_back(v); adj[v].push_back(u); } dfs(0, -1); cout << max(dp0[0], dp1[0]) << endl; return 0; }