#include <bits/stdc++.h>
using namespace std;
struct Line {
  long long a, b;
  Line() { a = 0, b = 1e18; }
  Line(long long a, long long b) { this->a = a, this->b = b; }
  long long operator()(long long x) { return 1LL * a * x + b; }
};
struct node {
  int lhs, rhs;
  Line line;
} lichao[10000010];
int nNode = 0;
int go(int id) {
  if (!id) {
    id = ++nNode;
    lichao[id].line = Line(0, 1e18);
  }
  return id;
}
void update(int root, Line nw, int L = -1e5, int R = 1e5) {
  int m = L + R >> 1;
  int lef = nw(L) < lichao[root].line(L);
  int mid = nw(m) < lichao[root].line(m);
  if (mid) {
    swap(nw, lichao[root].line);
  }
  if (R - L == 1) return;
  if (lef != mid)
    update(lichao[root].lhs = go(lichao[root].lhs), nw, L, m);
  else
    update(lichao[root].rhs = go(lichao[root].rhs), nw, m, R);
}
long long get(int root, int x, int L = -1e5, int R = 1e5) {
  int m = L + R >> 1;
  if (R - L == 1) return lichao[root].line(x);
  if (x < m)
    return min(lichao[root].line(x),
               get(lichao[root].lhs = go(lichao[root].lhs), x, L, m));
  else
    return min(lichao[root].line(x),
               get(lichao[root].rhs = go(lichao[root].rhs), x, m, R));
}
int n;
int root[100010], a[100010], b[100010];
long long dp[100010];
int in[100010], out[100010], ti, topo[100010];
int sz[100010];
vector<int> e[100010];
void dfs(int u, int p) {
  topo[++ti] = u, in[u] = ti;
  sz[u] = 1;
  int big = 0;
  for (auto v : e[u]) {
    if (v == p) continue;
    dfs(v, u);
    sz[u] += sz[v];
    if (sz[v] > sz[big]) big = v;
  }
  root[u] = root[big];
  if (!big)
    update(root[u] = go(root[u]), Line(b[u], 0));
  else {
    for (auto v : e[u]) {
      if (v == p || v == big) continue;
      for (int i = in[v]; i <= out[v]; ++i)
        update(root[u] = go(root[u]), Line(b[topo[i]], dp[topo[i]]));
    }
    dp[u] = get(root[u], a[u]);
    update(root[u] = go(root[u]), Line(b[u], dp[u]));
  }
  out[u] = ti;
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> b[i];
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(1, 0);
  for (int u = 1; u <= n; ++u) cout << dp[u] << " ";
}
