#include <bits/stdc++.h>
using namespace std;
char buf[1 << 20], *p1, *p2;
template <class T>
inline void read(T &n) {
  char ch =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
           ? 0
           : *p1++);
  T w = 1, x = 0;
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch =
        (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
             ? 0
             : *p1++);
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch =
        (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
             ? 0
             : *p1++);
  }
  n = x * w;
}
const int maxn = 100005;
struct line {
  int k;
  long long b;
  line(int _k = 0, long long _b = 0) { k = _k, b = _b; }
  friend bool operator<(line x, line y) {
    return x.k == y.k ? x.b < y.b : x.k < y.k;
  }
};
set<line> s[maxn];
int n, a[maxn], b[maxn];
int last[maxn], Next[maxn << 1], to[maxn << 1], cnt;
inline void addedge(int x, int y) {
  Next[++cnt] = last[x];
  last[x] = cnt, to[cnt] = y;
}
inline long double inter(line x, line y) {
  return (x.b - y.b) / (long double)(y.k - x.k);
}
void insert(int now, line x) {
  set<line>::iterator it = s[now].lower_bound(x);
  if (it != s[now].end() && (*it).k == x.k)
    s[now].erase(it);
  else if (it != s[now].begin() && (*--it).k == x.k)
    return;
  it = s[now].lower_bound(x);
  if (it != s[now].begin() && it != s[now].end()) {
    line R = *it, L = *(--it);
    long double tmp = inter(L, R);
    if (inter(L, x) < tmp && tmp < inter(R, x)) return;
  }
  while (1) {
    it = s[now].lower_bound(x);
    if (it == s[now].begin()) break;
    line R = *(--it);
    if (it == s[now].begin()) break;
    line L = *(--it);
    long double tmp = inter(L, x);
    if (inter(L, R) < tmp && tmp < inter(R, x))
      s[now].erase(++it);
    else
      break;
  }
  while (1) {
    it = s[now].lower_bound(x);
    if (it == s[now].end()) break;
    line L = *it;
    if ((++it) == s[now].end()) break;
    line R = *it;
    long double tmp = inter(R, x);
    if (inter(L, x) < tmp && tmp < inter(L, R))
      s[now].erase(--it);
    else
      break;
  }
  s[now].insert(x);
}
void merge(int x, int y) {
  if (s[x].size() < s[y].size()) swap(s[x], s[y]);
  for (auto it = s[y].begin(); it != s[y].end(); it++) insert(x, *it);
}
long long f[maxn];
void dfs(int x, int fa) {
  if (!Next[last[x]] && to[last[x]] == fa) {
    s[x].insert(line(b[x], 0));
    return;
  }
  for (int i = last[x]; i; i = Next[i]) {
    int v = to[i];
    if (v != fa) {
      dfs(v, x);
      merge(x, v);
    }
  }
  int l = -1e5, r = 1e5, res;
  while (l <= r) {
    int mid = (l + r) >> 1;
    auto it = s[x].lower_bound(line(mid, (long long)-1e15));
    if (it == s[x].begin()) {
      res = mid, l = mid + 1;
      continue;
    }
    if (it == s[x].end()) {
      r = mid - 1;
      continue;
    }
    line R = *it, L = *(--it);
    if (1ll * L.k * a[x] + L.b >= 1ll * R.k * a[x] + R.b)
      res = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  line now = *s[x].lower_bound(line(res, (long long)-1e15));
  f[x] = 1ll * now.k * a[x] + now.b;
  insert(x, line(b[x], f[x]));
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  for (int i = 1; i <= n; i++) read(b[i]);
  for (int i = 1, x, y; i < n; i++) {
    read(x), read(y);
    addedge(x, y), addedge(y, x);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) printf("%lld\n", f[i]);
  return 0;
}
