#include <bits/stdc++.h>
using namespace std;
void solve();
using ll = long long;
using vl = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {
  IoSetupNya() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(7);
  }
} iosetupnya;
template <typename T, typename U>
inline bool amin(T &x, U y) {
  return (y < x) ? (x = y, true) : false;
}
template <typename T, typename U>
inline bool amax(T &x, U y) {
  return (x < y) ? (x = y, true) : false;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  int s = (int)v.size();
  for (int i = 0; i < (s); i++) os << (i ? " " : "") << v[i];
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}
void in() {}
template <typename T, class... U>
void in(T &t, U &...u) {
  cin >> t;
  in(u...);
}
void out() { cout << "\n"; }
template <typename T, class... U>
void out(const T &t, const U &...u) {
  cout << t;
  if (sizeof...(u)) cout << " ";
  out(u...);
}
template <typename T>
void die(T x) {
  out(x);
  exit(0);
}
int main() { solve(); }
using P = pair<int, int>;
using vp = vector<P>;
constexpr int MOD = 998244353;
template <typename T, T INF>
struct DynamicLiChaoTree {
  struct Line {
    T slope, intercept;
    Line() : slope(0), intercept(INF) {}
    Line(T slope, T intercept) : slope(slope), intercept(intercept) {}
    inline T get(T x) const { return slope * x + intercept; }
    inline bool over(const Line &other, const T &x) const {
      return get(x) < other.get(x);
    }
  };
  T xmin, xmax, _size;
  unordered_map<T, Line> seg;
  DynamicLiChaoTree(T xmin, T xmax) : xmin(xmin), xmax(xmax) {
    _size = 1;
    while (_size < xmax - xmin + 1) _size <<= 1;
  }
  void update(T a, T b, T left, T right, T seg_idx) {
    Line line(a, b);
    while (1) {
      int mid = (left + right) >> 1;
      bool l_over = line.over(seg[seg_idx], min(xmax, left + xmin));
      bool r_over = line.over(seg[seg_idx], min(xmax, right - 1 + xmin));
      if (l_over == r_over) {
        if (l_over) swap(seg[seg_idx], line);
        return;
      }
      bool m_over = line.over(seg[seg_idx], min(xmax, mid + xmin));
      if (m_over) swap(seg[seg_idx], line);
      if (l_over != m_over)
        seg_idx = (seg_idx << 1), right = mid;
      else
        seg_idx = (seg_idx << 1) | 1, left = mid;
    }
  }
  void update(T a, T b, T seg_idx) {
    T left, right;
    T upper_bit = 63 - __builtin_clzll(seg_idx);
    left = (_size >> upper_bit) * (seg_idx - (1 << upper_bit));
    right = left + (_size >> upper_bit);
    update(a, b, left, right, seg_idx);
  }
  void update(T a, T b) { update(a, b, 0, _size, 1); }
  void update_line_segment(T a, T b, T left, T right) {
    left -= xmin - _size, right -= xmin - _size - 1;
    for (; left < right; left >>= 1, right >>= 1) {
      if (left & 1) update(a, b, left++);
      if (right & 1) update(a, b, --right);
    }
  }
  T query(T x) {
    T left = 0, right = _size, seg_idx = 1, idx = x - xmin, ret = INF;
    while (1) {
      T cur = seg[seg_idx].get(x);
      ret = min(ret, cur);
      if (left + 1 >= right) break;
      int mid = (left + right) >> 1;
      if (idx < mid)
        seg_idx = (seg_idx << 1), right = mid;
      else
        seg_idx = (seg_idx << 1) | 1, left = mid;
    }
    return ret;
  }
  void merge(DynamicLiChaoTree<T, INF> &other) {
    if (seg.size() < other.seg.size()) seg.swap(other.seg);
    for (auto &x : other.seg) {
      if (x.second.intercept == INF) continue;
      update(x.second.slope, x.second.intercept, x.first);
    }
  }
};
int N;
vvi g;
template <typename G>
G convert_rooted_tree(const G &g, int r = 0) {
  int N = (int)g.size();
  G rg(N);
  vector<int> v(N);
  v[r] = 1;
  queue<int> que;
  que.emplace(r);
  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    for (auto &to : g[p]) {
      if (v[to] == 0) {
        v[to] = 1;
        que.emplace(to);
        rg[p].emplace_back(to);
      }
    }
  }
  return rg;
}
vl dp, a, b;
void merge(DynamicLiChaoTree<ll, infLL> &lichao, int cur) {
  if (g[cur].size() == 0) {
    lichao.update(b[cur], dp[cur]);
    return;
  }
  for (int i = 0; i < ((int)(g[cur]).size()); i++) {
    DynamicLiChaoTree<ll, infLL> lichao2(-100000, 100000);
    merge(lichao2, g[cur][i]);
    lichao.merge(lichao2);
  }
  dp[cur] = lichao.query(a[cur]);
  lichao.update(b[cur], dp[cur]);
}
void solve() {
  in(N);
  a.resize(N);
  b.resize(N);
  in(a, b);
  g.resize(N);
  for (int i = 0; i < (N - 1); i++) {
    int x, y;
    in(x, y);
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vvi rg = convert_rooted_tree(g);
  g.swap(rg);
  dp.resize(N, 0);
  DynamicLiChaoTree<ll, infLL> lichao(-100000, 100000);
  merge(lichao, 0);
  out(dp);
}
