#include <bits/stdc++.h>
using namespace std;
struct line {
  long long a, b;
  double xleft;
  bool type;
  line(long long _a, long long _b) {
    a = _a;
    b = _b;
    type = 0;
  }
  bool operator<(const line& other) const {
    if (other.type) {
      return xleft < other.xleft;
    }
    return a > other.a;
  }
};
double meet(line x, line y) { return 1.0 * (y.b - x.b) / (x.a - y.a); }
struct cht {
  set<line> hull;
  cht() { hull.clear(); }
  bool hasleft(set<line>::iterator node) { return node != hull.begin(); }
  bool hasright(set<line>::iterator node) { return node != prev(hull.end()); }
  void updateborder(set<line>::iterator node) {
    if (hasright(node)) {
      line temp = *next(node);
      hull.erase(temp);
      temp.xleft = meet(*node, temp);
      hull.insert(temp);
    }
    if (hasleft(node)) {
      line temp = *node;
      temp.xleft = meet(*prev(node), temp);
      hull.erase(node);
      hull.insert(temp);
    } else {
      line temp = *node;
      hull.erase(node);
      temp.xleft = -1e18;
      hull.insert(temp);
    }
  }
  bool useless(line left, line middle, line right) {
    double x = meet(left, right);
    double y = x * middle.a + middle.b;
    double ly = left.a * x + left.b;
    return y > ly;
  }
  bool useless(set<line>::iterator node) {
    if (hasleft(node) && hasright(node)) {
      return useless(*prev(node), *node, *next(node));
    }
    return 0;
  }
  void addline(long long a, long long b) {
    line temp = line(a, b);
    auto it = hull.lower_bound(temp);
    if (it != hull.end() && it->a == a) {
      if (it->b > b) {
        hull.erase(it);
      } else {
        return;
      }
    }
    hull.insert(temp);
    it = hull.find(temp);
    if (useless(it)) {
      hull.erase(it);
      return;
    }
    while (hasleft(it) && useless(prev(it))) {
      hull.erase(prev(it));
    }
    while (hasright(it) && useless(next(it))) {
      hull.erase(next(it));
    }
    updateborder(it);
  }
  long long getbest(long long x) {
    if (hull.empty()) {
      return 1e18;
    }
    line query(0, 0);
    query.xleft = x;
    query.type = 1;
    auto it = hull.lower_bound(query);
    it = prev(it);
    return it->a * x + it->b;
  }
};
template <typename T>
void printvec(vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << " ";
  }
  cout << endl;
}
const int N = 100 * 1000 + 5;
long long n;
vector<long long> a(N), b(N);
vector<vector<long long> > adj(N);
vector<long long> ans;
cht vec[N];
void dfs(long long curr, long long prev) {
  long long i;
  long long bigchild = -1;
  bool isleaf = true;
  for (i = 0; i < adj[curr].size(); i++) {
    if (adj[curr][i] == prev) continue;
    isleaf = false;
    dfs(adj[curr][i], curr);
    if (bigchild == -1 ||
        vec[bigchild].hull.size() < vec[adj[curr][i]].hull.size())
      bigchild = adj[curr][i];
  }
  if (!isleaf) swap(vec[curr], vec[bigchild]);
  for (i = 0; i < adj[curr].size(); i++) {
    if (adj[curr][i] == prev || adj[curr][i] == bigchild) continue;
    set<line>::iterator it;
    for (it = vec[adj[curr][i]].hull.begin();
         it != vec[adj[curr][i]].hull.end(); it++) {
      vec[curr].addline(it->a, it->b);
    }
  }
  if (isleaf)
    ans[curr] = 0;
  else
    ans[curr] = vec[curr].getbest(a[curr]);
  vec[curr].addline(b[curr], ans[curr]);
}
int main() {
  std::ios::sync_with_stdio(false);
  int ttt = 1;
  while (ttt--) {
    long long n, i;
    scanf("%lld", &n);
    ans.resize(n);
    for (i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
    }
    for (i = 0; i < n; i++) {
      scanf("%lld", &b[i]);
    }
    for (i = 0; i < n - 1; i++) {
      long long a, b;
      scanf("%lld%lld", &a, &b);
      a--;
      b--;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    dfs(0, -1);
    printvec(ans);
  }
  return 0;
}
