#include <bits/stdc++.h>
using namespace std;
const long long MAX = (1LL << 55);
const long long N = 100005;
struct qq {
  long long x, y, last;
} e[N * 2];
long long num, last[N];
long long n;
long long a[N], B[N];
void init(long long x, long long y) {
  num++;
  e[num].x = x;
  e[num].y = y;
  e[num].last = last[x];
  last[x] = num;
}
long long ans[N];
long long tot[N], son[N];
void dfs(long long x, long long fa) {
  tot[x] = 1;
  for (long long u = last[x]; u != -1; u = e[u].last) {
    long long y = e[u].y;
    if (y == fa) continue;
    dfs(y, x);
    tot[x] += tot[y];
    if (tot[y] > tot[son[x]]) son[x] = y;
  }
}
long long s1[N * 8], s2[N * 8], k[N], b[N];
long long tr[N * 8];
long long root;
bool Jud(long long x, long long y, long long pos) {
  return b[x] + k[x] * pos < b[y] + k[y] * pos;
}
void change(long long &now, long long l, long long r, long long x) {
  if (now == 0) {
    now = ++num;
    tr[now] = x;
    s1[now] = 0;
    s2[now] = 0;
    return;
  }
  if (l == r) {
    if (Jud(x, tr[now], l)) tr[now] = x;
    return;
  }
  long long mid = (l + r) >> 1;
  if (k[x] < k[tr[now]]) {
    if (Jud(x, tr[now], mid))
      change(s1[now], l, mid, tr[now]), tr[now] = x;
    else
      change(s2[now], mid + 1, r, x);
  } else {
    if (Jud(x, tr[now], mid))
      change(s2[now], mid + 1, r, tr[now]), tr[now] = x;
    else
      change(s1[now], l, mid, x);
  }
}
long long get(long long x, long long y) { return k[x] * y + b[x]; }
long long get_min(long long now, long long l, long long r, long long x) {
  if (now == 0) return MAX;
  long long mid = (l + r) >> 1;
  long long ans = get(tr[now], x);
  if (x <= mid)
    ans = min(ans, get_min(s1[now], l, mid, x));
  else
    ans = min(ans, get_min(s2[now], mid + 1, r, x));
  return ans;
}
void Dfs(long long xx, long long x, long long fa) {
  ans[xx] = min(ans[xx], ans[x] + B[x] * a[xx]);
  change(root, -100000, 100000, x);
  for (long long u = last[x]; u != -1; u = e[u].last) {
    long long y = e[u].y;
    if (y == fa) continue;
    Dfs(xx, y, x);
  }
}
void solve(long long x, long long fa) {
  if (son[x] == 0) {
    k[x] = B[x];
    b[x] = 0;
    change(root, -100000, 100000, x);
    return;
  }
  for (long long u = last[x]; u != -1; u = e[u].last) {
    long long y = e[u].y;
    if (y == fa || y == son[x]) continue;
    solve(y, x);
  }
  root = num = 0;
  solve(son[x], x);
  ans[x] = get_min(root, -100000, 100000, a[x]);
  for (int u = last[x]; u != -1; u = e[u].last) {
    int y = e[u].y;
    if (y == fa || y == son[x]) continue;
    Dfs(x, y, x);
  }
  k[x] = B[x];
  b[x] = ans[x];
  change(root, -100000, 100000, x);
}
int main() {
  num = 0;
  memset(last, -1, sizeof(last));
  scanf("%I64d", &n);
  for (long long u = 1; u <= n; u++) scanf("%I64d", &a[u]);
  for (long long u = 1; u <= n; u++) scanf("%I64d", &B[u]);
  for (long long u = 1; u < n; u++) {
    long long x, y;
    scanf("%I64d%I64d", &x, &y);
    init(x, y);
    init(y, x);
  }
  dfs(1, 0);
  num = 0;
  solve(1, 0);
  for (long long u = 1; u <= n; u++) printf("%I64d ", ans[u]);
  return 0;
}
