#include <bits/stdc++.h>
using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf;
template <class T>
void read(T &x) {
  x = 0;
  int c = getchar();
  int flag = 0;
  while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
template <class T>
T _max(T a, T b) {
  return b < a ? a : b;
}
template <class T>
T _min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
bool checkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
bool checkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
const int N = 100005, delta = 100001, Range = 200002;
int n, a[N], b[N];
int e = 0, first[N], nxt[N << 1], point[N << 1];
long long ans[N];
int rt[N];
struct Line {
  long long k, b;
  int idx;
  Line() {
    k = b = 0;
    idx = 0;
  }
  Line(long long K, long long B, int i) : k(K), b(B), idx(i) {}
  long long f(int x) { return k * x + b; }
};
bool gt(Line a, Line b, int x) {
  if (a.idx == 0) return 1;
  return a.f(x) > b.f(x);
}
const int M = 200005 * 29;
struct seg {
  int cnt;
  int lson[M], rson[M];
  Line P[M];
  seg() { cnt = 0; }
  void Insert(int &x, int l, int r, Line now) {
    if (!x) x = ++cnt;
    int mid = (l + r) >> 1;
    if (gt(P[x], now, mid)) {
      swap(P[x], now);
    }
    if (l == r || P[x].k == now.k || now.idx == 0) return;
    if (P[x].f(l) <= now.f(l) && P[x].f(r) <= now.f(r)) return;
    if (now.k > P[x].k)
      Insert(lson[x], l, mid, now);
    else
      Insert(rson[x], mid + 1, r, now);
  }
  int merge(int x, int y, int l, int r) {
    if (!x || !y) return x | y;
    int mid = (l + r) >> 1;
    Insert(x, l, r, P[y]);
    lson[x] = merge(lson[x], lson[y], l, mid);
    rson[x] = merge(rson[x], rson[y], mid + 1, r);
    return x;
  }
  Line query(int x, int l, int r, int pos) {
    if (!x || l == r) return P[x];
    int mid = (l + r) >> 1;
    Line now = (pos <= mid) ? query(lson[x], l, mid, pos)
                            : query(rson[x], mid + 1, r, pos);
    if (gt(now, P[x], pos)) now = P[x];
    return now;
  }
} T;
void add_edge(int x, int y) {
  nxt[++e] = first[x];
  first[x] = e;
  point[e] = y;
}
void init() {
  read(n);
  memset(first, -1, sizeof first);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1; i <= n; ++i) read(b[i]);
  for (int i = 1, u, v; i < n; ++i) {
    read(u);
    read(v);
    add_edge(u, v);
    add_edge(v, u);
  }
}
void ask(int x) {
  int idx = T.query(rt[x], 1, Range, a[x] + delta).idx;
  ans[x] = ans[idx] + (long long)a[x] * b[idx];
}
void add_line(int x) {
  long long k = b[x], b = ans[x] - k * delta;
  T.Insert(rt[x], 1, Range, Line(k, b, x));
}
void dfs(int x, int f) {
  for (int i = first[x]; ~i; i = nxt[i]) {
    int to = point[i];
    if (to == f) continue;
    dfs(to, x);
    rt[x] = T.merge(rt[x], rt[to], 1, Range);
  }
  ask(x);
  if (x > 1) add_line(x);
}
void solve() {
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) printf("%lld%c", ans[i], " \n"[i == n]);
}
int main() {
  init();
  solve();
  return 0;
}
