#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long inf = 1e18;
int n, a[N], b[N], tag[N * 20], cnt, tot, rt[N], ls[N * 20], rs[N * 20];
vector<int> e[N];
struct func {
  int k;
  long long b;
} f[N];
long long dp[N];
inline long long Y(int id, int x) { return 1ll * f[id].k * x + f[id].b; }
void modify(int &p, int l, int r, int x) {
  if (!p) {
    p = ++cnt, tag[p] = x;
    return;
  }
  int mid = l + r >> 1;
  if (Y(x, mid) <= Y(tag[p], mid)) swap(x, tag[p]);
  if (Y(tag[p], l) <= Y(x, l) && Y(tag[p], r) <= Y(x, r)) return;
  if (Y(x, l) < Y(tag[p], l))
    modify(ls[p], l, mid, x);
  else
    modify(rs[p], mid + 1, r, x);
}
int merge(int p1, int p2, int l, int r) {
  if (!p1 || !p2) return p1 | p2;
  modify(p1, l, r, tag[p2]);
  int mid = l + r >> 1;
  ls[p1] = merge(ls[p1], ls[p2], l, mid);
  rs[p1] = merge(rs[p1], rs[p2], mid + 1, r);
  return p1;
}
long long query(int p, int l, int r, int x) {
  if (!p) return inf;
  int mid = l + r >> 1;
  return min(Y(tag[p], x),
             mid >= x ? query(ls[p], l, mid, x) : query(rs[p], mid + 1, r, x));
}
void dfs(int u, int fa) {
  for (auto v : e[u])
    if (v != fa) dfs(v, u), rt[u] = merge(rt[u], rt[v], -1e5, 1e5);
  dp[u] = query(rt[u], -1e5, 1e5, a[u]);
  if (dp[u] == inf) dp[u] = 0;
  f[++tot] = {b[u], dp[u]};
  modify(rt[u], -1e5, 1e5, tot);
}
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, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) printf("%lld ", dp[i]);
  return 0;
}
