#include <bits/stdc++.h>
using namespace std;
long long f(pair<long long, long long> a, long long b) {
  return (a.first * b + a.second);
}
const long long INF = 1e15;
struct node {
  pair<long long, long long> val = {0, INF};
  long long l = 0, r = 0;
};
vector<node> tree;
void add(long long i, long long l, long long r,
         pair<long long, long long> now) {
  if (l + 1 != r && tree[i].l == 0) {
    node c;
    tree[i].l = ((long long)(tree).size());
    tree.push_back(c);
    tree[i].r = ((long long)(tree).size());
    tree.push_back(c);
  }
  long long m = (l + r) / 2;
  bool lef = f(now, l) < f(tree[i].val, l);
  bool mid = f(now, m) < f(tree[i].val, m);
  if (mid) {
    swap(tree[i].val, now);
  }
  if (l + 1 == r)
    return;
  else if (lef != mid)
    add(tree[i].l, l, m, now);
  else
    add(tree[i].r, m, r, now);
}
long long get(long long i, long long l, long long r, long long first) {
  long long m = (l + r) / 2;
  if (i == 0) {
    return INF;
  }
  if (l + 1 == r)
    return f(tree[i].val, first);
  else if (first < m) {
    return min(f(tree[i].val, first), get(tree[i].l, l, m, first));
  } else
    return min(f(tree[i].val, first), get(tree[i].r, m, r, first));
}
const long long N = 1e5 + 5;
long long a[N], b[N];
long long root[N];
vector<pair<long long, long long> > d[N];
vector<long long> g[N];
long long ans[N];
long long sub[N];
void dfs(long long v, long long p = -1) {
  sub[v] = 1;
  if (((long long)(g[v]).size()) + (p == -1) < 2) {
    ans[v] = 0;
    pair<long long, long long> c;
    c = {b[v], 0};
    add(root[v], -N, N, c);
    d[v].push_back(c);
    return;
  }
  long long in = -1;
  long long vv = 0;
  for (long long u : g[v]) {
    if (u != p) {
      dfs(u, v);
      sub[v] += sub[u];
      if (sub[u] > vv) {
        vv = sub[u];
        in = u;
      }
    }
  }
  for (long long u : g[v]) {
    if (u == in) {
      swap(d[v], d[u]);
      root[v] = root[u];
    }
  }
  for (long long u : g[v]) {
    if (u != in && u != p) {
      for (pair<long long, long long> c : d[u]) {
        d[v].push_back(c);
        add(root[v], -N, N, c);
      }
    }
  }
  ans[v] = get(root[v], -N, N, a[v]);
  pair<long long, long long> c;
  c = {b[v], ans[v]};
  d[v].push_back(c);
  add(root[v], -N, N, c);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  node c;
  tree.push_back(c);
  for (long long i = 0; i < n; ++i) {
    root[i] = ((long long)(tree).size());
    tree.push_back(c);
  }
  for (long long i = 0; i < n; ++i) cin >> a[i];
  for (long long i = 0; i < n; ++i) cin >> b[i];
  for (long long i = 0; i < n - 1; ++i) {
    long long fr, to;
    cin >> fr >> to;
    --fr;
    --to;
    g[fr].push_back(to);
    g[to].push_back(fr);
  }
  dfs(0);
  for (long long i = 0; i < n; ++i) cout << ans[i] << " ";
  return 0;
}
