#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
inline void file() { freopen("P4512_3.in", "r", stdin); }
char buf[1 << 21], *p1 = buf, *p2 = buf;
inline long long getc() {
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  register long long ret = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = ret * 10 + ch - 48;
    ch = getchar();
  }
  return f ? -ret : ret;
}
struct node {
  long long son[2], val;
} t[200005 * 32];
struct line {
  long long k, b;
  inline long long calc(long long x) { return k * x + b; }
} L[200005];
long long cntt, root[200005];
vector<long long> e[200005];
long long n, a[200005], b[200005], u, v;
long long f[200005];
void insert(long long& x, long long l, long long r, long long k) {
  if (!x) {
    x = ++cntt;
    t[x].son[0] = t[x].son[1] = 0;
    t[x].val = k;
    return;
  }
  const long long mid = l + r >> 1;
  long long now = L[t[x].val].calc(mid), tmp = L[k].calc(mid);
  if (now > tmp) swap(t[x].val, k), swap(now, tmp);
  if (L[t[x].val].calc(l) <= L[k].calc(l) &&
      L[t[x].val].calc(r) <= L[k].calc(r))
    return;
  if (L[t[x].val].calc(l) > L[k].calc(l))
    insert(t[x].son[0], l, mid, k);
  else
    insert(t[x].son[1], mid + 1, r, k);
}
long long merge(long long x, long long y, long long l, long long r) {
  if (!x || !y) return x + y;
  insert(x, l, r, t[y].val);
  const long long mid = l + r >> 1;
  t[x].son[0] = merge(t[x].son[0], t[y].son[0], l, mid);
  t[x].son[1] = merge(t[x].son[1], t[y].son[1], mid + 1, r);
  return x;
}
long long query(long long x, long long l, long long r, long long y) {
  if (!x) return 0x7fffffffffffffff;
  long long ret = L[t[x].val].calc(y);
  const long long mid = l + r >> 1;
  if (y <= mid)
    ret = min(ret, query(t[x].son[0], l, mid, y));
  else
    ret = min(ret, query(t[x].son[1], mid + 1, r, y));
  return ret;
}
void dfs(long long x, long long fa) {
  for (auto y : e[x]) {
    if (y == fa) continue;
    dfs(y, x);
    root[x] = merge(root[x], root[y], 1, 200005);
  }
  f[x] = query(root[x], 1, 200005, a[x] + 100001ll);
  if (f[x] >= 0x7fffffffffffffff) f[x] = 0;
  L[x].k = b[x];
  L[x].b = f[x] - 100001ll * b[x];
  insert(root[x], 1, 200005, x);
}
signed main() {
  n = read();
  for (register long long i = 1; i <= n; ++i) a[i] = read();
  for (register long long i = 1; i <= n; ++i) b[i] = read();
  for (register long long i = 1; i < n; ++i) {
    u = read(), v = read();
    e[u].push_back(v), e[v].push_back(u);
  }
  dfs(1, 0);
  for (register long long i = 1; i <= n; ++i) printf("%lld ", f[i]);
  return 0;
}
