#include <bits/stdc++.h>
using namespace std;
long long dp[100005], a[100005], b[100005];
vector<long long> G[100005];
struct line {
  long long m, b;
  line(long long _m = 0, long long _b = 0) { m = _m, b = _b; }
  long long at(long long x) { return m * x + b; }
};
struct nd {
  line L;
  nd *l, *r;
  long long sz;
  nd() {
    l = r = nullptr;
    L = line();
    sz = 1;
  }
};
long long size(nd* t) { return t ? t->sz : 0; }
void upd(nd*& t, line nw, long long tl = -100000, long long tr = 100001) {
  if (!t) {
    t = new nd();
    t->L = nw;
    return;
  }
  long long tm = (tl + tr) / 2;
  if ((t->L).at(tm) > nw.at(tm)) swap(t->L, nw);
  if (tr - tl == 1) return;
  if ((t->L).at(tl) > nw.at(tl))
    upd(t->l, nw, tl, tm);
  else if ((t->L).at(tr - 1) > nw.at(tr - 1))
    upd(t->r, nw, tm, tr);
  t->sz = 1 + size(t->l) + size(t->r);
}
long long qry(nd*& t, long long x, long long tl = -100000,
              long long tr = 100001) {
  if (tr - tl == 1) return (t->L).at(x);
  long long tm = (tl + tr) / 2;
  long long ret = (t->L).at(x);
  if (x <= tm && t->l)
    ret = min(ret, qry(t->l, x, tl, tm));
  else if (x > tm && t->r)
    ret = min(ret, qry(t->r, x, tm, tr));
  return ret;
}
void mycopy(nd* t, nd* tt) {
  if (!tt) return;
  upd(t, tt->L);
  mycopy(t, tt->l);
  mycopy(t, tt->r);
  delete tt;
}
nd* dfs(long long u, long long p = -1) {
  nd* t = nullptr;
  for (long long v : G[u])
    if (v != p) {
      nd* tt = dfs(v, u);
      if (size(t) < size(tt)) swap(t, tt);
      mycopy(t, tt);
    }
  if (t) dp[u] = qry(t, a[u]);
  line L(b[u], dp[u]);
  upd(t, L);
  return t;
}
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) cin >> b[i];
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1);
  for (long long i = 1; i <= n; i++) cout << dp[i] << " ";
}
