#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int mxn = 1e5 + 5;
struct line {
  long long m, c;
  long long operator()(long long x) { return m * x + c; }
};
struct node {
  line seg;
  node *lc, *rc;
  node(line _seg) : seg(_seg), lc(NULL), rc(NULL) {}
};
typedef node* pnode;
void insert(pnode nd, int cl, int cr, line seg) {
  if (cr - cl == 1) {
    if (seg(cl) < nd->seg(cl)) nd->seg = seg;
    return;
  }
  int md = (cl + cr) / 2;
  if (seg.m < nd->seg.m) swap(seg, nd->seg);
  if (nd->seg(md) > seg(md)) {
    swap(seg, nd->seg);
    if (nd->rc)
      insert(nd->rc, md, cr, seg);
    else
      nd->rc = new node(seg);
  } else {
    if (nd->lc)
      insert(nd->lc, cl, md, seg);
    else
      nd->lc = new node(seg);
  }
}
long long query(pnode nd, int cl, int cr, long long x) {
  if (cr - cl == 1) return nd->seg(x);
  int md = (cl + cr) / 2;
  if (x < md && nd->lc)
    return min(nd->seg(x), query(nd->lc, cl, md, x));
  else if (nd->rc)
    return min(nd->seg(x), query(nd->rc, md, cr, x));
  else
    return nd->seg(x);
}
void del(pnode nd) {
  if (nd->lc) del(nd->lc);
  if (nd->rc) del(nd->rc);
  delete nd;
}
void merge(pnode cont, pnode nw) {
  if (nw->seg.m != 0 || nw->seg.c != inf) insert(cont, -mxn, mxn, nw->seg);
  if (nw->lc) merge(cont, nw->lc);
  if (nw->rc) merge(cont, nw->rc);
}
int n;
long long a[mxn], b[mxn], dp[mxn];
vector<int> adj[mxn];
pair<int, pnode> dfs(int nw, int bf) {
  int sz = 0;
  pnode root = new node((line){0, inf});
  for (int nx : adj[nw])
    if (nx != bf) {
      int sznx;
      pnode child;
      tie(sznx, child) = dfs(nx, nw);
      if (sz < sznx) swap(root, child);
      merge(root, child);
      del(child);
      sz += sznx;
    }
  dp[nw] = (sz ? query(root, -mxn, mxn, a[nw]) : 0);
  insert(root, -mxn, mxn, (line){b[nw], dp[nw]});
  return {sz + 1, root};
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) printf("%lld ", dp[i]);
  return 0;
}
