#include <bits/stdc++.h>
template <typename _Tp>
inline void read(_Tp &x) {
  x = 0;
  bool fg = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fg ^= 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (_Tp)(ch ^ 48), ch = getchar();
  if (fg) x = -x;
}
template <typename _Tp, typename... Args>
void read(_Tp &t, Args &...args) {
  read(t);
  read(args...);
}
using namespace std;
const int N = 200010;
const int MAX = 100000;
const long long inf = 0x3f3f3f3f3f3f3f3f;
long long a[N], b[N], ans[N];
int head[N], pnt[N << 1], nxt[N << 1], E, n;
struct line {
  long long k, b;
  line() {
    k = 0;
    b = inf;
  }
  line(const long long &_k, const long long &_b) : k(_k), b(_b) {}
  long long operator()(const long long &x) { return k * x + b; }
};
struct node {
  int l, r;
  line x;
} t[N * 23];
int tot, root[N];
void adde(int u, int v) {
  E++;
  pnt[E] = v;
  nxt[E] = head[u];
  head[u] = E;
}
int newnode() {
  ++tot;
  t[tot] = {0, 0, line()};
  return tot;
}
void modify(int &p, int L, int R, line u, int l = -MAX, int r = MAX) {
  if (!p) p = newnode();
  int mid = (l + r) >> 1;
  if (L <= l && r <= R) {
    line v = t[p].x;
    long long ru = u(mid), rv = v(mid);
    if (l == r) {
      t[p].x = (ru < rv) ? u : v;
      return;
    }
    if (u.k > v.k) {
      if (ru < rv) {
        t[p].x = u;
        modify(t[p].r, L, R, v, mid + 1, r);
      } else
        modify(t[p].l, L, R, u, l, mid);
    } else if (u.k < v.k) {
      if (ru < rv) {
        t[p].x = u;
        modify(t[p].l, L, R, v, l, mid);
      } else
        modify(t[p].r, L, R, u, mid + 1, r);
    } else {
      t[p].x = (u.b < v.b) ? u : v;
    }
    return;
  }
  if (L <= mid) modify(t[p].l, L, R, u, l, mid);
  if (R > mid) modify(t[p].r, L, R, u, mid + 1, r);
}
long long query(int p, int ps, int l = -MAX, int r = MAX) {
  if (!p) return inf;
  if (l == r) return t[p].x(ps);
  int mid = (l + r) >> 1;
  long long ret = 0;
  if (ps <= mid)
    ret = query(t[p].l, ps, l, mid);
  else
    ret = query(t[p].r, ps, mid + 1, r);
  return min(ret, t[p].x(ps));
}
int merge(int p, int q, int l = -MAX, int r = MAX) {
  if (!p || !q) return p + q;
  int mid = (l + r) >> 1;
  modify(p, l, r, t[q].x, l, r);
  if (l < r) {
    t[p].l = merge(t[p].l, t[q].l, l, mid);
    t[p].r = merge(t[p].r, t[q].r, mid + 1, r);
  }
  return p;
}
void print(int p, int l = -MAX, int r = MAX) {
  if (!p) return;
  int mid = (l + r) >> 1;
  fprintf(stderr, "> [%d,%d] %lldx+%lld\n", l, r, t[p].x.k, t[p].x.b);
  fflush(stderr);
  print(t[p].l, l, mid);
  print(t[p].r, mid + 1, r);
}
int tim, dfn[N];
void dfs(int u, int f) {
  bool isleaf = 1;
  dfn[++tim] = u;
  for (int i = head[u]; i; i = nxt[i]) {
    int v = pnt[i];
    if (v == f) continue;
    dfs(v, u);
    isleaf = 0;
    dfn[++tim] = u;
    root[u] = merge(root[u], root[v]);
  }
  ans[u] = isleaf ? 0 : query(root[u], a[u]);
  line t(b[u], ans[u]);
  modify(root[u], -MAX, MAX, t);
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1; i <= n; ++i) read(b[i]);
  for (int i = 1; i < n; ++i) {
    int u, v;
    read(u, v);
    adde(u, v);
    adde(v, u);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) {
    printf("%lld%c", ans[i], " \n"[i == n]);
  }
  return 0;
}
