#include <bits/stdc++.h>
using namespace std;
bool Q;
struct Line {
  mutable long long k, m, p;
  bool operator<(const Line& o) const { return Q ? p < o.p : k < o.k; }
};
struct LineContainer : multiset<Line> {
  const long long inf = LLONG_MAX;
  long long div(long long a, long long b) {
    return a / b - ((a ^ b) < 0 && a % b);
  }
  bool isect(iterator x, iterator y) {
    if (y == end()) {
      x->p = inf;
      return false;
    }
    assert(x->k <= y->k);
    if (x->k == y->k)
      x->p = x->m > y->m ? inf : -inf;
    else
      x->p = div(y->m - x->m, x->k - y->k);
    return x->p >= y->p;
  }
  void add(long long k, long long m) {
    auto z = insert({k, m, 0}), y = z++, x = y;
    while (isect(y, z)) z = erase(z);
    if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
    while ((y = x) != begin() && (--x)->p >= y->p) isect(x, erase(y));
  }
  long long query(long long x) {
    assert(!empty());
    Q = 1;
    auto l = *lower_bound({0, 0, x});
    Q = 0;
    return l.k * x + l.m;
  }
};
vector<int> x, y;
vector<vector<int> > adj;
vector<long long> ans;
vector<int> subsize;
void dfs1(int u, int v) {
  subsize[u] = 1;
  for (auto i : adj[u]) {
    if (i == v) continue;
    dfs1(i, u);
    subsize[u] += subsize[i];
  }
}
void dfs2(int v, int p, LineContainer& cur) {
  int mx = -1, bigChild = -1;
  bool leaf = 1;
  for (auto u : adj[v]) {
    if (u != p and subsize[u] > mx) {
      mx = subsize[u];
      bigChild = u;
      leaf = 0;
    }
  }
  if (bigChild != -1) {
    dfs2(bigChild, v, cur);
  }
  for (auto u : adj[v]) {
    if (u != p and u != bigChild) {
      LineContainer temp;
      dfs2(u, v, temp);
      for (auto i : temp) {
        cur.add(i.k, i.m);
      }
    }
  }
  if (!leaf)
    ans[v] = -cur.query(x[v]);
  else
    ans[v] = 0;
  cur.add(-y[v], -ans[v]);
}
void solve() {
  int n;
  cin >> n;
  x.resize(n + 1);
  y.resize(n + 1);
  ans.resize(n + 1);
  subsize.resize(n + 1);
  adj.resize(n + 1);
  for (int i = 1; i < n + 1; i++) cin >> x[i];
  for (int i = 1; i < n + 1; i++) cin >> y[i];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs1(1, 0);
  LineContainer lc;
  dfs2(1, 0, lc);
  for (int i = 1; i < n + 1; i++) cout << ans[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
