#include <bits/stdc++.h>
using namespace std;
class line {
 public:
  long long k, m;
  bool operator<(const line &o) const {
    return k < o.k || (k == o.k && m < o.m);
  }
  bool operator==(const line &o) const { return k == o.k && m == o.m; }
};
const int Maxn = 1e5 + 5;
const long long INF = 1e18 + 5;
int n, u, v;
int a[Maxn], b[Maxn], pt[Maxn];
vector<int> adj[Maxn];
long long dp[Maxn];
set<line> s[Maxn];
bool check(line l1, line l2, line l3) {
  double d =
      1.0 * (l3.k - l1.k) * (l2.m - l1.m) - 1.0 * (l2.k - l1.k) * (l3.m - l1.m);
  if (d >= 0) return true;
  return false;
}
void insert(int id, line o) {
  if (s[id].size() < 2) {
    s[id].insert(o);
    return;
  }
  set<line>::iterator r = s[id].lower_bound(o), l = r, t;
  if (r != s[id].end() && *r == o) return;
  if (l != s[id].begin()) {
    l--;
    if (r != s[id].end() && check(*l, o, *r)) return;
    s[id].insert(o);
    while (l != s[id].begin()) {
      t = l--;
      if (check(*l, *t, o)) {
        s[id].erase(t);
      } else
        break;
    }
  }
  if (r != s[id].end()) {
    t = r++;
    while (r != s[id].end()) {
      if (check(o, *t, *r)) {
        s[id].erase(t);
        t = r++;
      } else
        break;
    }
  }
}
long long gety(line o, int x) { return o.m + (long long)x * o.k; }
long long calc(int id, int x) {
  int lb = -Maxn, ub = Maxn + 1, mi;
  set<line>::iterator it;
  while (ub - lb > 1) {
    mi = (ub + lb) >> 1;
    it = s[id].lower_bound(line{mi, INF});
    if (it != s[id].begin() && gety(*prev(it), x) < gety(*it, x))
      ub = mi;
    else
      lb = mi;
  }
  it = s[id].lower_bound(line{lb, INF});
  return gety(*it, x);
}
void merge(int id1, int id2) {
  for (auto v : s[id1]) {
    insert(id2, v);
  }
}
void dfs(int now, int pre) {
  int weight = 0, big = now;
  for (auto nxt : adj[now]) {
    if (nxt != pre) {
      dfs(nxt, now);
      if (s[pt[nxt]].size() > weight) {
        weight = s[pt[nxt]].size();
        big = nxt;
      }
    }
  }
  pt[now] = pt[big];
  if (big == now) {
    dp[now] = 0;
    pt[now] = now;
    insert(now, line{-Maxn, INF});
    insert(now, line{Maxn, INF});
    insert(now, line{b[now], 0});
    return;
  }
  for (auto nxt : adj[now]) {
    if (nxt != pre && nxt != big) {
      merge(pt[nxt], pt[big]);
    }
  }
  dp[now] = calc(pt[now], a[now]);
  insert(pt[now], line{b[now], dp[now]});
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) scanf("%d", b + i);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 1);
  for (int i = 1; i <= n; i++) printf("%I64d ", dp[i]);
  printf("\n");
  return 0;
}
