#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll is_query = -LLONG_MAX;
struct Line {
  ll m, b;
  mutable function<const Line*()> succ;
  bool operator<(const Line& rhs) const {
    if (rhs.b != is_query) return m < rhs.m;
    const Line* s = succ();
    if (!s) return 0;
    ll x = rhs.m;
    return b - s->b < (s->m - m) * x;
  }
};
struct HullDynamic : public multiset<Line> {
  bool bad(iterator y) {
    auto z = next(y);
    if (y == begin()) {
      if (z == end()) return 0;
      return y->m == z->m && y->b <= z->b;
    }
    auto x = prev(y);
    if (z == end()) return y->m == x->m && y->b <= x->b;
    return ld(x->b - y->b) * (z->m - y->m) >= ld(y->b - z->b) * (y->m - x->m);
  }
  void insert_line(ll m, ll b) {
    auto y = insert({-m, -b});
    if (bad(y)) {
      erase(y);
      return;
    }
    while (next(y) != end() && bad(next(y))) erase(next(y));
    y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };
    while (y != begin() && bad(prev(y))) erase(prev(y));
    if (y != begin()) prev(y)->succ = [=] { return &*y; };
  }
  ll eval(ll x) {
    auto l = *lower_bound((Line){x, is_query});
    return -(l.m * x + l.b);
  }
};
const int N = 1e5 + 5;
HullDynamic hull[N];
int to[N];
ll dp[N], A[N], B[N];
std::vector<int> g[N];
void dfs(int u, int p = 0) {
  std::vector<int> childTo;
  int big = 0;
  for (auto v : g[u]) {
    if (v == p) continue;
    dfs(v, u);
    if (int(hull[to[v]].size()) > big) {
      to[u] = to[v];
      big = int(hull[to[v]].size());
    }
    childTo.push_back(to[v]);
  }
  for (auto v : childTo) {
    if (v == to[u]) continue;
    for (auto x : hull[v]) {
      hull[to[u]].insert_line(-x.m, -x.b);
    }
    hull[v].clear();
  }
  if (big) dp[u] = hull[to[u]].eval(A[u]);
  hull[to[u]].insert_line(B[u], dp[u]);
  childTo.clear();
}
int main() {
  int n, x, y;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    to[i] = i;
  }
  for (int i = 1; i <= n; i++) cin >> B[i];
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1);
  cout << dp[1];
  for (int i = 2; i <= n; i++) cout << ' ' << dp[i];
  cout << '\n';
  return 0;
}
