#include <bits/stdc++.h>
inline int read() {
  int data = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
  return data * w;
}
const long long INF(1e18);
const int N(1e5 + 10), LogN(18), M(1e5);
struct node {
  long long k, b;
} t[N * LogN];
long long F(const node &f, int x) { return f.k * x + f.b; }
struct edge {
  int next, to;
} e[N << 1];
int n, head[N], e_num, cur, son[2][N * LogN], a[N], b[N], rt[N];
long long f[N];
inline void Add(int from, int to) {
  e[++e_num] = (edge){head[from], to}, head[from] = e_num;
}
void Insert(node f, int &x, int l = -M, int r = M) {
  if (!x) return (void)(t[x = ++cur] = f);
  int mid = (l + r) / 2;
  if (F(t[x], mid) > F(f, mid)) std::swap(f, t[x]);
  if (F(t[x], l) <= F(f, l) && F(t[x], r) <= F(f, r)) return;
  if (F(f, l) < F(t[x], l))
    Insert(f, son[0][x], l, mid);
  else
    Insert(f, son[1][x], mid + 1, r);
}
long long Query(int x0, int x, int l = -M, int r = M) {
  if (!x) return INF;
  if (l == r) return F(t[x], x0);
  int mid = (l + r) / 2;
  long long f = F(t[x], x0);
  if (x0 <= mid)
    return std::min(f, Query(x0, son[0][x], l, mid));
  else
    return std::min(f, Query(x0, son[1][x], mid + 1, r));
}
int merge(int x, int y, int l = -M, int r = M) {
  if (!x || !y) return x | y;
  int mid = (l + r) / 2;
  Insert(t[y], x, l, r);
  son[0][x] = merge(son[0][x], son[0][y], l, mid);
  son[1][x] = merge(son[1][x], son[1][y], mid + 1, r);
  return x;
}
void dfs(int x, int fa) {
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].to != fa) dfs(e[i].to, x), rt[x] = merge(rt[x], rt[e[i].to]);
  f[x] = Query(a[x], rt[x]);
  if (f[x] == INF) f[x] = 0;
  Insert((node){b[x], f[x]}, rt[x]);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) b[i] = read();
  for (int i = 1, a, b; i < n; i++)
    a = read(), b = read(), Add(a, b), Add(b, a);
  dfs(1, 0);
  for (int i = 1; i <= n; i++) printf("%lld%c", f[i], " \n"[i == n]);
  return 0;
}
