#include <bits/stdc++.h>
using namespace std;
const long long M = 1e5 + 1;
template <typename T>
inline void read(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  x *= f;
}
struct edge {
  int u, v, next;
  edge(int u, int v, int next) : u(u), v(v), next(next) {}
  edge() {}
} e[100005 << 1];
int head[100005], k;
inline void add(int u, int v) {
  e[k] = edge(u, v, head[u]);
  head[u] = k++;
}
int n;
struct line {
  long long k, b;
  bool flag;
  line(long long k = 0, long long b = 0, bool flag = 0)
      : k(k), b(b), flag(flag) {}
  inline long long calcu(int pos) {
    if (!flag) return 0x3f3f3f3f3f3f3f3f;
    return k * (pos - M) + b;
  }
  inline double cross(const line &T) { return (double)(T.b - b) / (k - T.k); }
} tree[100005 << 3];
int rt[100005], tot, ch[100005 << 3][2];
inline void modify(int &p, int l, int r, int L, int R, line ln) {
  if (!p) p = ++tot;
  if (L <= l && r <= R) {
    long long lp = tree[p].calcu(l), rp = tree[p].calcu(r);
    long long lq = ln.calcu(l), rq = ln.calcu(r);
    if (!tree[p].flag)
      tree[p] = ln;
    else if (lq <= lp && rq <= rp)
      tree[p] = ln;
    else if (lq <= lp || rq <= rp) {
      int mid = (l + r) >> 1;
      if (ln.calcu(mid) < tree[p].calcu(mid)) swap(ln, tree[p]);
      double cross = ln.cross(tree[p]) + M;
      if (cross < mid || (cross == mid && ln.calcu(l) < tree[p].calcu(l)))
        modify(ch[p][0], l, mid, L, R, ln);
      else
        modify(ch[p][1], mid + 1, r, L, R, ln);
    }
  } else {
    int mid = (l + r) >> 1;
    if (L <= mid) modify(ch[p][0], l, mid, L, R, ln);
    if (R > mid) modify(ch[p][1], mid + 1, r, L, R, ln);
  }
}
inline long long query(int p, int l, int r, int ps) {
  if (!p) return 0x3f3f3f3f3f3f3f3f;
  long long ans = tree[p].calcu(ps);
  if (l == r) return ans;
  int mid = (l + r) >> 1;
  if (ps <= mid)
    return min(ans, query(ch[p][0], l, mid, ps));
  else
    return min(ans, query(ch[p][1], mid + 1, r, ps));
}
inline int merge(int x, int y, int l, int r) {
  if (!x || !y) return x | y;
  int mid = (l + r) >> 1;
  ch[x][0] = merge(ch[x][0], ch[y][0], l, mid);
  ch[x][1] = merge(ch[x][1], ch[y][1], mid + 1, r);
  modify(x, l, r, l, r, tree[y]);
  return x;
}
long long a[100005], b[100005];
long long f[100005];
inline void dfs(int u, int fa) {
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs(v, u);
    rt[u] = merge(rt[u], rt[v], 1, M << 1);
  }
  if (rt[u]) f[u] = query(rt[u], 1, M << 1, a[u]);
  modify(rt[u], 1, M << 1, 1, M << 1, line(b[u], f[u], true));
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]), a[i] += M;
  for (int i = 1; i <= n; ++i) read(b[i]);
  memset(head, -1, sizeof(head));
  for (int i = 1, u, v; i < n; ++i) {
    read(u), read(v);
    add(u, v);
    add(v, u);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) printf("%lld ", f[i]);
  return 0;
}
