#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int HullType = 0;
const long long inf = 1e18;
struct line {
  long long a, b;
  bool is_query;
  mutable double line_x;
  line() {
    a = 0;
    b = 0;
    line_x = 0;
    is_query = 0;
  }
  line(long long _a, long long _b) {
    a = _a;
    b = _b;
    line_x = 0;
    is_query = 0;
  }
  line(long long _a, long long _b, bool _is_query, double _line_x) {
    a = _a;
    b = _b;
    is_query = _is_query;
    line_x = _line_x;
  };
  bool operator<(const line &l2) const {
    if (!is_query && !l2.is_query)
      return HullType == 0 ? (a > l2.a) : (a < l2.a);
    else
      return line_x < l2.line_x;
  }
  long long value_at(long long x) const { return a * x + b; }
};
struct DynamicHull : set<line> {
  double intersect_x(const line &l1, const line &l2) {
    if (l1.a == l2.a) return (double)inf;
    return (double)(l1.b - l2.b) / (double)(l2.a - l1.a);
  }
  bool has_next(iterator it) { return it != end() && next(it) != end(); }
  bool has_prev(iterator it) { return it != end() && it != begin(); }
  bool irrelevant(const line &l1, const line &l2, const line &l3) {
    return intersect_x(l1, l3) <= intersect_x(l1, l2);
  }
  bool irrelevant(iterator it) {
    return has_prev(it) && has_next(it) &&
           irrelevant(*prev(it), *it, *next(it));
  }
  void update_border(iterator it) {
    if (has_next(it))
      it->line_x = intersect_x(*it, *next(it));
    else
      it->line_x = inf;
  }
  void add(long long a, long long b) {
    line curr_line = line(a, b);
    iterator it = lower_bound(curr_line);
    if (it != end() && it->a == a) {
      if ((HullType == 0 && it->b > b) || (HullType == 1 && it->b < b))
        it = erase(it);
      else
        return;
    }
    it = insert(it, curr_line);
    if (irrelevant(it)) {
      erase(it);
      return;
    }
    while (has_prev(it) && irrelevant(prev(it))) erase(prev(it));
    while (has_next(it) && irrelevant(next(it))) erase(next(it));
    update_border(it);
    if (has_prev(it)) update_border(prev(it));
    if (has_next(it)) update_border(next(it));
  }
  long long query(long long x) {
    if (empty()) return HullType == 0 ? inf : -inf;
    return lower_bound(line(0, 0, 1, x))->value_at(x);
  }
};
DynamicHull *h[maxn];
vector<int> v[maxn];
long long res[maxn];
int n, a[maxn], b[maxn], sz[maxn];
void DFS(int u, int p) {
  sz[u] = 1;
  for (int c : v[u])
    if (c != p) {
      DFS(c, u);
      sz[u] += sz[c];
    }
}
void DSU(int u, int p) {
  int big = -1;
  for (int c : v[u])
    if (c != p && (big == -1 || sz[c] > sz[big])) big = c;
  if (big == -1)
    h[u] = new DynamicHull;
  else
    DSU(big, u), h[u] = h[big];
  for (int c : v[u])
    if (c != p && c != big) {
      DSU(c, u);
      for (line d : (*h[c])) h[u]->add(d.a, d.b);
    }
  if (big != -1) res[u] = h[u]->query(a[u]);
  h[u]->add(b[u], res[u]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (fopen(""
            ".INP",
            "r"))
    freopen(
        ""
        ".INP",
        "r", stdin),
        freopen(
            ""
            ".OUT",
            "w", stdout);
  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; ++i) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  DFS(1, 0);
  DSU(1, 0);
  for (int i = 1; i <= n; ++i) cout << res[i] << " ";
  return 0;
}
