#include <bits/stdc++.h>
using namespace std;
long long seed = time(0);
mt19937 gen(seed);
bool IS_ONE_TEST = 1;
struct LiChao {
  struct line {
    long long k = 0, b = 1e18;
    line() : k(0), b(1e18){};
    line(long long k, long long b) : k(k), b(b){};
    long long get(long long x) { return (long long)k * (x - 1e5) + b; }
  };
  vector<int> L, R;
  vector<line> t;
  int create() {
    int new_vertex = t.size();
    L.emplace_back(-1);
    R.emplace_back(-1);
    t.emplace_back(line());
    return new_vertex;
  }
  LiChao() {
    L = {-1};
    R = {-1};
    t = {line()};
  }
  int size() { return t.size(); }
  long long ask(long long x) { return ask(0, 0, 2e5, x + 1e5); }
  long long ask(int v, int vl, int vr, int x) {
    if (vl == vr)
      return t[v].get(x);
    else {
      int vm = (vl + vr) / 2;
      if (x <= vm) {
        if (L[v] == -1) return t[v].get(x);
        return min(t[v].get(x), ask(L[v], vl, vm, x));
      } else {
        if (R[v] == -1) return t[v].get(x);
        return min(t[v].get(x), ask(R[v], vm + 1, vr, x));
      }
    }
  }
  void add_line(line l) { add_line(0, 0, 2e5, l); }
  void add_line(int v, int vl, int vr, line l) {
    if (l.b == 1e18) return;
    if (vl == vr) {
      if (t[v].get(vl) > l.get(vl)) swap(t[v], l);
      return;
    } else {
      int vm = (vl + vr) / 2;
      if (t[v].get(vm) > l.get(vm)) swap(t[v], l);
      bool f = (l.get(vl) < t[v].get(vl));
      if (f) {
        if (L[v] == -1) {
          int V = create();
          L[v] = V;
        }
        add_line(L[v], vl, vm, l);
      } else {
        if (R[v] == -1) {
          int V = create();
          R[v] = V;
        }
        add_line(R[v], vm + 1, vr, l);
      }
    }
  }
  void merge(LiChao &Li) { merge(0, Li); }
  void merge(int v, LiChao &Li) {
    if (L[v] != -1) merge(L[v], Li);
    if (R[v] != -1) merge(R[v], Li);
    Li.add_line(t[v]);
  }
  void clear() {
    L.clear();
    R.clear();
    t.clear();
  }
};
void solve() {
  mt19937 local_gen(152);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  vector<vector<int>> g(n);
  vector<LiChao> t(n);
  vector<long long> dp(n);
  for (int i = 0; i + 1 < n; ++i) {
    int x, y;
    cin >> x >> y;
    g[x - 1].emplace_back(y - 1);
    g[y - 1].emplace_back(x - 1);
  }
  function<void(int, int)> dfs = [&](int v, int p) {
    for (auto &elem : g[v])
      if (elem != p) dfs(elem, v);
    if ((g[v].size() == 1 && p != -1) || (g[v].size() == 0 && p == -1))
      dp[v] = 0;
    else {
      int u = 0;
      if (g[v][u] == p) ++u;
      for (int i = 0; i < g[v].size(); ++i) {
        if (g[v][i] == p) continue;
        if (t[g[v][i]].size() < t[g[v][u]].size()) u = i;
      }
      for (int i = 0; i < g[v].size(); ++i) {
        if (i == u || g[v][i] == p) continue;
        t[g[v][i]].merge(t[g[v][u]]);
        t[g[v][i]].clear();
      }
      dp[v] = t[g[v][u]].ask(a[v]);
      t[v] = t[g[v][u]];
      t[g[v][u]].clear();
    }
    t[v].add_line(LiChao::line(b[v], dp[v]));
  };
  dfs(0, -1);
  for (int i = 0; i < n; ++i) cout << dp[i] << " ";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  srand(time(0));
  cout << fixed << setprecision(15);
  int T = 1;
  if (!IS_ONE_TEST) cin >> T;
  while (T-- > 0) solve();
}
