#include <bits/stdc++.h>
const long long inf = LLONG_MAX;
const int infl = -1e5, infr = 1e5;
int tot = 0, num = 0, cnt = 0;
long long b[300005], k[300005], res[300005];
int a[300005], c[300005];
int head[300005], to[600005], nxt[600005];
int rt[300005], ls[5000005], rs[5000005], tag[5000005];
inline int read() {
  register int x = 0, f = 1;
  register char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
inline void add(int x, int y) {
  to[++cnt] = y;
  nxt[cnt] = head[x];
  head[x] = cnt;
}
inline long long min(long long x, long long y) { return x < y ? x : y; }
inline long long calc(long long x, int id) { return k[id] * x + b[id]; }
inline void change(int &p, int l, int r, int id) {
  if (!p) {
    tag[p = ++tot] = id;
    return;
  }
  if (l == r) {
    if (calc(l, id) < calc(l, tag[p])) tag[p] = id;
    return;
  }
  int mid = l + r >> 1;
  if (k[id] < k[tag[p]]) {
    if (calc(mid, id) <= calc(mid, tag[p])) {
      change(ls[p], l, mid, tag[p]);
      tag[p] = id;
    } else {
      change(rs[p], mid + 1, r, id);
    }
  } else if (k[id] > k[tag[p]]) {
    if (calc(mid, id) <= calc(mid, tag[p])) {
      change(rs[p], mid + 1, r, tag[p]);
      tag[p] = id;
    } else {
      change(ls[p], l, mid, id);
    }
  } else if (b[id] < b[tag[p]]) {
    tag[p] = id;
    return;
  }
}
inline long long ask(int p, int l, int r, int x) {
  if (!p) return inf;
  if (l == r) return calc(l, tag[p]);
  int mid = l + r >> 1;
  long long minn = calc(x, tag[p]);
  if (x <= mid)
    return min(minn, ask(ls[p], l, mid, x));
  else
    return min(minn, ask(rs[p], mid + 1, r, x));
}
inline int merge(int x, int y, int l, int r) {
  if (!x || !y) return x + y;
  if (l == r) return calc(l, tag[x]) > calc(l, tag[y]) ? y : x;
  int mid = l + r >> 1;
  ls[x] = merge(ls[x], ls[y], l, mid);
  rs[x] = merge(rs[x], rs[y], mid + 1, r);
  change(x, l, r, tag[y]);
  return x;
}
inline void dfs(int x, int fa) {
  int du = 0;
  for (register int i = head[x]; i; i = nxt[i]) {
    int y = to[i];
    if (y == fa) continue;
    dfs(y, x);
    ++du;
    rt[x] = merge(rt[x], rt[y], infl, infr);
  }
  k[++num] = c[x];
  if (du)
    res[x] = b[num] = ask(rt[x], infl, infr, a[x]);
  else
    res[x] = b[num] = 0;
  change(rt[x], infl, infr, num);
}
signed main() {
  int n = read();
  for (register int i = 1; i <= n; ++i) a[i] = read();
  for (register int i = 1; i <= n; ++i) c[i] = read();
  for (register int i = 1; i < n; ++i) {
    int x = read(), y = read();
    add(x, y);
    add(y, x);
  }
  dfs(1, -1);
  for (register int i = 1; i <= n; ++i) printf("%lld ", res[i]);
  return 0;
}
