#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct li_chao_tree {
  struct line {
    int a;
    T b;
    line() {}
    line(int _a, T _b) {
      a = _a;
      b = _b;
    }
    T eval(int x) const { return static_cast<T>(a) * x + b; }
  };
  struct node {
    node* left;
    node* right;
    line best;
    node(line L) {
      left = right = 0;
      best = L;
    }
  };
  const function<bool(T, T)> op = less<T>();
  const int MIN = -1e5 - 5;
  const int MAX = 1e5 + 5;
  const T INF = 3e18 + 5;
  node* root = 0;
  int sz = 0;
  void add(node*& n, int l, int r, line ln) {
    if (!n) {
      n = new node(ln);
      sz++;
      return;
    }
    int m = l + (r - l) / 2;
    if (op(ln.eval(m), n->best.eval(m))) {
      swap(ln, n->best);
    }
    if (op(ln.eval(l), n->best.eval(l))) {
      add(n->left, l, m - 1, ln);
    } else if (op(ln.eval(r), n->best.eval(r))) {
      add(n->right, m + 1, r, ln);
    }
  }
  void add_line(int a, T b) { add(root, MIN, MAX, line(a, b)); }
  T query(int x) const {
    assert(MIN <= x && x <= MAX);
    T ans = INF;
    node* n = root;
    int l = MIN;
    int r = MAX;
    while (n) {
      int m = l + (r - l) / 2;
      ans = min(ans, n->best.eval(x));
      if (x < m) {
        n = n->left;
        r = m - 1;
      } else if (x > m) {
        n = n->right;
        l = m + 1;
      } else {
        break;
      }
    }
    return ans;
  }
  void traverse(function<void(int, T)> f) const {
    vector<node*> s;
    if (root) s.push_back(root);
    while (s.size()) {
      node* n = s.back();
      s.pop_back();
      f(n->best.a, n->best.b);
      if (n->left) s.push_back(n->left);
      if (n->right) s.push_back(n->right);
    }
  }
};
template <typename T>
li_chao_tree<T>* merge(li_chao_tree<T>* a, li_chao_tree<T>* b) {
  if (a->sz < b->sz) swap(a, b);
  auto f = [&](int la, T lb) { a->add_line(la, lb); };
  b->traverse(f);
  delete b;
  return a;
}
void foo() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<vector<int>> adj(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  vector<int> p(n, -1);
  vector<long long> dp(n);
  vector<li_chao_tree<long long>*> lines(n);
  function<void(int)> dfs = [&](int v) {
    lines[v] = new li_chao_tree<long long>();
    for (int u : adj[v]) {
      if (p[v] == u) continue;
      p[u] = v;
      dfs(u);
      lines[v] = merge(lines[v], lines[u]);
    }
    if (lines[v]->sz) {
      dp[v] = lines[v]->query(a[v]);
    }
    lines[v]->add_line(b[v], dp[v]);
  };
  dfs(0);
  for (int i = 0; i < n; i++) {
    cout << dp[i] << " ";
  }
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  foo();
}
