#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:16777216")
using namespace std;
using matrix = vector<vector<long long>>;
void FAST_IO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long INF = 1e12;
struct line {
  long long k, b;
  line() : k(0), b(INF){};
  line(long long _k, long long _b) : k(_k), b(_b){};
  long long val(long long x) { return k * x + b; }
};
struct node {
  node *l, *r;
  line x;
  node() : l(nullptr), r(nullptr), x(line()){};
};
const int MAXN = 1e5 + 100;
long long a[MAXN], b[MAXN];
long long dp[MAXN];
node *roots[MAXN];
vector<line> *elements[MAXN];
vector<int> g[MAXN];
void insert(node *&root, int tl, int tr, line new_line) {
  int tm = (tl + tr) / 2;
  if (root->x.val(tm) > new_line.val(tm)) {
    swap(root->x, new_line);
  }
  if (tl + 1 == tr) {
    return;
  }
  if (root->x.val(tl) > new_line.val(tl)) {
    if (root->l == nullptr) {
      root->l = new node();
    }
    insert(root->l, tl, tm, new_line);
  } else {
    if (root->r == nullptr) {
      root->r = new node();
    }
    insert(root->r, tm, tr, new_line);
  }
}
long long get(node *&root, int tl, int tr, int pos) {
  if (tl + 1 == tr) {
    return root->x.val(pos);
  }
  int tm = (tl + tr) / 2;
  long long a = INF;
  if (pos < tm) {
    if (root->l != nullptr) {
      a = get(root->l, tl, tm, pos);
    }
  } else {
    if (root->r != nullptr) {
      a = get(root->r, tm, tr, pos);
    }
  }
  return min(root->x.val(pos), a);
}
void merge(int u, int v) {
  if (elements[u]->size() < elements[v]->size()) {
    swap(elements[u], elements[v]);
    swap(roots[u], roots[v]);
  }
  for (line i : *elements[v]) {
    insert(roots[u], -MAXN, MAXN, i);
    elements[u]->push_back(i);
  }
}
void dfs(int u, int p) {
  for (int to : g[u]) {
    if (to == p) {
      continue;
    }
    dfs(to, u);
    merge(u, to);
  }
  dp[u] = get(roots[u], -MAXN, MAXN, a[u]);
  if (dp[u] == INF) {
    dp[u] = 0;
  }
  insert(roots[u], -MAXN, MAXN, line(b[u], dp[u]));
  elements[u]->push_back(line(b[u], dp[u]));
}
signed main() {
  FAST_IO();
  int n;
  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 = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    roots[i] = new node();
    elements[i] = new vector<line>;
  }
  dfs(1, -1);
  for (int i = 1; i <= n; ++i) {
    cout << dp[i] << ' ';
  }
}
