#include <bits/stdc++.h>
using namespace std;
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 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 (__int128)(x->b - y->b) * (z->m - y->m) >=
           (__int128)(y->b - z->b) * (y->m - x->m);
  }
  void insert_line(long long m, long long 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;
  }
};
const int N = 1e5 + 5;
long long a[N], b[N], subtree[N], ans[N];
vector<int> V[N];
void dfs(int s, int pr) {
  subtree[s] = 1;
  for (int u : V[s]) {
    if (u == pr) continue;
    subtree[s] += subtree[u];
  }
}
void smallToLarge(int s, int pr, HullDynamic& cur) {
  int mx = -1, bigchild = -1;
  for (int u : V[s]) {
    if (u == pr) continue;
    if (subtree[u] > mx) {
      mx = subtree[u];
      bigchild = u;
    }
  }
  if (bigchild != -1) smallToLarge(bigchild, s, cur);
  for (int u : V[s]) {
    if (u != pr and u != bigchild) {
      HullDynamic tmp;
      smallToLarge(u, s, tmp);
      for (auto it : tmp) {
        cur.insert_line(it.m, it.b);
      }
    }
  }
  if (bigchild == -1)
    ans[s] = 0;
  else
    ans[s] = -cur.eval(a[s]);
  cur.insert_line(-b[s], -ans[s]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  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 = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    V[u].push_back(v);
    V[v].push_back(u);
  }
  dfs(1, 0);
  HullDynamic cur;
  smallToLarge(1, 0, cur);
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
}
