#include <bits/stdc++.h>
using namespace std;
bool Q = false;
struct line {
  mutable long long int m, c;
  mutable long double x;
  line(long long int M, long long int C, long long int X) : m(M), c(C), x(X) {}
  bool operator<(const line& next) const {
    if (Q == false) {
      return m > next.m;
    } else
      return x < next.x;
  }
  long long int get(long long int X) { return m * X + c; }
};
struct hull : multiset<line> {
  long double cross(iterator a, iterator b) {
    long double A = a->m, B = a->c, C = b->m, D = b->c;
    return (D - B) / (A - C);
  }
  bool isect(iterator a, iterator b) {
    if (b == end()) {
      a->x = 100000000000000000;
      return false;
    }
    if (a->m == b->m)
      a->x = ((a->c > b->c) ? -100000000000000000 : 100000000000000000);
    else
      a->x = cross(a, b);
    return a->x >= b->x;
  }
  void add(long long int M, long long int C) {
    iterator pre, curr, next;
    curr = insert(line(M, C, 0));
    next = pre = curr;
    next++;
    while (isect(curr, next)) next = erase(next);
    if (curr != begin() && isect(--pre, curr)) isect(pre, curr = erase(curr));
    while ((curr = pre) != begin() && (--pre)->x >= curr->x)
      isect(pre, erase(curr));
  }
  long long int query(long long int X) {
    Q = true;
    line curr = *lower_bound(line(0, 0, X));
    Q = false;
    return curr.get(X);
  }
};
vector<long long int> adj[100005];
vector<long long int> A(100005), B(100005);
vector<long long int> dp(100005, 0);
hull H[100005];
void dfs(long long int x, long long int pre) {
  for (long long int i = 0; i < adj[x].size(); i++) {
    long long int y = adj[x][i];
    if (y == pre) continue;
    dfs(y, x);
    if (H[y].size() > H[x].size()) swap(H[y], H[x]);
    for (hull::iterator itr = H[y].begin(); itr != H[y].end(); itr++) {
      H[x].add(itr->m, itr->c);
    }
  }
  if (H[x].empty())
    dp[x] = 0;
  else
    dp[x] = H[x].query(A[x]);
  H[x].add(B[x], dp[x]);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) cin >> A[i];
  for (long long int i = 1; i <= n; i++) cin >> B[i];
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, -1);
  for (long long int i = 1; i <= n; i++) {
    cout << dp[i] << " ";
  }
}
