#include <bits/stdc++.h>
using namespace std;
const long long N = 100003, OO = 1110111110111, mod = 1000000007,
                mod2 = 998244353;
int n, l, r;
int sz[N];
long long dp[N], a[N], b[N];
vector<int> adj[N];
const long long is_query = -(1LL << 62);
struct Line {
  long long 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;
    long long x = rhs.m;
    return b - s->b < (s->m - m) * x;
  }
};
struct CHT : 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 (long double)(x->b - y->b) * (z->m - y->m) >=
           (long double)(y->b - z->b) * (y->m - x->m);
  }
  void insert_line(long long m, long long b) {
    m = -m;
    b = -b;
    auto y = insert({m, b});
    y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };
    if (bad(y)) {
      erase(y);
      return;
    }
    while (next(y) != end() && bad(next(y))) erase(next(y));
    while (y != begin() && bad(prev(y))) erase(prev(y));
  }
  long long eval(long long x) {
    auto l = *lower_bound((Line){x, is_query});
    return -(l.m * x + l.b);
  }
};
CHT* c[N];
int calc(int x, int p) {
  sz[x] = 1;
  for (auto u : adj[x]) {
    if (u == p) continue;
    sz[x] += calc(u, x);
  }
  return sz[x];
}
void dfs(int x, int p) {
  int big = 0, mx = -1;
  for (int u : adj[x]) {
    if (u == p) continue;
    dfs(u, x);
    if (sz[u] > mx) {
      mx = sz[u];
      big = u;
    }
  }
  if (mx == -1)
    c[x] = new CHT();
  else
    c[x] = c[big];
  for (int u : adj[x]) {
    if (u == p || u == big) continue;
    for (auto j : *c[u]) c[x]->insert_line(-j.m, -j.b);
  }
  if (big) dp[x] = c[x]->eval(a[x]);
  c[x]->insert_line(b[x], dp[x]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 0; i < n - 1; i++) {
    cin >> l >> r;
    adj[l].push_back(r);
    adj[r].push_back(l);
  }
  calc(1, 1);
  dfs(1, 1);
  for (int i = 1; i <= n; i++) cout << dp[i] << " ";
  return 0;
}
