#include <bits/stdc++.h>
using namespace std;
inline int Int() {
  int x;
  scanf("%d", &x);
  return x;
}
inline long long Long() {
  long long x;
  scanf("%lld", &x);
  return x;
}
void err(istream_iterator<string> it) { cout << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ' ';
  err(++it, args...);
}
const int N = (int)2e5 + 5;
const int maxN = (int)1e6 + 6;
const long long Mod = (long long)1e9 + 7;
const int inf = (int)2e9;
const long long Inf = (long long)1e18;
const int mod = (int)1e9 + 7;
inline int add(int a, int b) {
  a += b;
  return a >= mod ? a - mod : a;
}
inline int mul(int a, int b) { return (long long)a * b % mod; }
long long dp[N];
vector<vector<int>> g;
int sub[N], a[N], b[N];
bool tp;
struct Line {
  mutable long long m, c, p;
  bool operator<(const Line& u) const { return !tp ? m < u.m : p < u.p; }
  bool operator<(long long u) { return p < u; }
};
struct DynamicCHT : multiset<Line> {
  long long div(long long a, long long b) {
    return a / b - ((a ^ b) < 0 and a % b);
  }
  bool isect(iterator x, iterator y) {
    if (y == end()) {
      x->p = Inf;
      return false;
    }
    if (x->m == y->m)
      x->p = x->c > y->c ? Inf : -Inf;
    else
      x->p = div(x->c - y->c, y->m - x->m);
    return x->p >= y->p;
  }
  void add(long long x, long long y) {
    auto c = insert({x, y, 0}), b = c++, a = b;
    while (isect(b, c)) c = erase(c);
    if (a != begin() and isect(--a, b)) isect(a, b = erase(b));
    while ((b = a) != begin() and (--a)->p >= b->p) isect(a, erase(b));
  }
  long long query(long long x) {
    assert(!empty());
    tp = 1;
    auto u = *lower_bound({0, 0, x});
    tp = 0;
    return u.m * x + u.c;
  }
};
void dfs(int s, int p = 0) {
  sub[s] = 1;
  for (int i : g[s]) {
    if (i == p) continue;
    dfs(i, s);
    sub[s] += sub[i];
  }
}
void SmallToLargeTrick(int s, int p, DynamicCHT& cur) {
  bool leaf = 1;
  int mx = -1, bigchild = -1;
  for (int i : g[s]) {
    if (i != p and mx < sub[i]) {
      mx = sub[i];
      bigchild = i;
      leaf = 0;
    }
  }
  if (~bigchild) SmallToLargeTrick(bigchild, s, cur);
  for (int i : g[s]) {
    if (i == bigchild or i == p) continue;
    DynamicCHT tmp;
    SmallToLargeTrick(i, s, tmp);
    for (auto j : tmp) {
      cur.add(j.m, j.c);
    }
  }
  if (!leaf)
    dp[s] = -cur.query(1LL * a[s]);
  else
    dp[s] = 0;
  cur.add(-1LL * b[s], -dp[s]);
}
int main() {
  int test = 1, tc = 0;
  while (test--) {
    int n = Int();
    g.resize(n + 1);
    for (int i = 1; i <= n; ++i) a[i] = Int();
    for (int i = 1; i <= n; ++i) b[i] = Int();
    for (int i = 1; i < n; ++i) {
      int x = Int(), y = Int();
      g[x].push_back(y);
      g[y].push_back(x);
    }
    dfs(1, 0);
    DynamicCHT res;
    SmallToLargeTrick(1, 0, res);
    for (int i = 1; i <= n; ++i) cout << dp[i] << " \n"[i == n];
  }
  return 0;
}
