#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const long long INF = 1e18;
template <typename T>
inline T read() {
  T sum = 0, fl = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fl = -1;
  for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
  return sum * fl;
}
const int maxn = 1e5 + 5;
const int maxv = 1e5;
int n, c;
int a[maxn], b[maxn], RT[maxn];
long long f[maxn];
int he[maxn], ne[maxn << 1], to[maxn << 1];
inline void add_edge(int first, int second) {
  ne[++c] = he[first];
  he[first] = c;
  to[c] = second;
  ne[++c] = he[second];
  he[second] = c;
  to[c] = first;
}
namespace SEG {
int c;
struct Node {
  int id, lc, rc;
} o[maxn * 60];
inline long long culc(int first, int id) {
  return (long long)first * b[id] + f[id];
}
void insert(int& rt, int l, int r, int id) {
  if (!rt) {
    o[rt = ++c].id = id;
    return;
  }
  if (culc((floor((l + r) / 2.0)), id) < culc((floor((l + r) / 2.0)), o[rt].id))
    swap(o[rt].id, id);
  if (l == r) return;
  if (culc(l, id) < culc(l, o[rt].id))
    insert(o[rt].lc, l, (floor((l + r) / 2.0)), id);
  if (culc(r, id) < culc(r, o[rt].id))
    insert(o[rt].rc, (floor((l + r) / 2.0)) + 1, r, id);
}
void query(int rt, int l, int r, int first) {
  if (o[rt].id)
    f[first] = min(f[first], culc(a[first], o[rt].id));
  else
    return;
  if (l == r) return;
  if (a[first] <= (floor((l + r) / 2.0)))
    query(o[rt].lc, l, (floor((l + r) / 2.0)), first);
  else
    query(o[rt].rc, (floor((l + r) / 2.0)) + 1, r, first);
}
void merge(int _rt, int& rt, int l, int r) {
  if (!o[_rt].id || !o[rt].id) return (void)(rt = _rt | rt);
  insert(rt, l, r, o[_rt].id);
  if (l == r) return;
  merge(o[_rt].lc, o[rt].lc, l, (floor((l + r) / 2.0)));
  merge(o[_rt].rc, o[rt].rc, (floor((l + r) / 2.0)) + 1, r);
}
}  // namespace SEG
void dfs(int p, int fa) {
  for (int i = he[p]; i; i = ne[i]) {
    if (to[i] == fa) continue;
    dfs(to[i], p);
    SEG ::insert(RT[p], -maxv, maxv, to[i]);
  }
  if (RT[p] == 0)
    f[p] = 0;
  else {
    f[p] = LLONG_MAX;
    SEG ::query(RT[p], -maxv, maxv, p);
    if (f) SEG ::merge(RT[p], RT[fa], -maxv, maxv);
  }
}
inline void solve() {
  n = read<int>();
  for (int i = 1; i <= n; ++i) a[i] = read<int>();
  for (int i = 1; i <= n; ++i) b[i] = read<int>();
  for (int i = 1; i < n; ++i) add_edge(read<int>(), read<int>());
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) printf("%lld ", f[i]);
}
int main() {
  solve();
  return 0;
}
