#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16 + 10;
bool cmp;
inline long long div(long long a, int b) { return a / b - (a < 0 && a % b); }
struct Line {
  mutable int k;
  mutable long long b, xr;
  bool operator<(const Line &n) const { return cmp ? xr < n.xr : k < n.k; }
  void isect(const Line &n) const {
    assert(k <= n.k);
    if (k == n.k) {
      xr = (b > n.b) ? INF : -INF;
    } else {
      xr = div(b - n.b, n.k - k);
    }
  }
  void display() const { printf("y = %dx + %I64d, xr = %I64d\n", k, b, xr); }
};
struct LowConvHull : public multiset<Line> {
  void ins(const Line &l) {
    iterator m = insert(l), n = m++;
    for (; m != end();) {
      n->isect(*m);
      if (n->xr >= m->xr) {
        m = erase(m);
      } else {
        break;
      }
    }
    if (m == end()) {
      n->xr = INF;
    }
    if (n == begin()) {
      return;
    }
    (--(m = n))->isect(*n);
    if (m->xr >= n->xr) {
      n = erase(n);
      if (n == end()) {
        m->xr = INF;
      } else {
        m->isect(*n);
      }
      return;
    }
    for (; (n = m) != begin() && (--m)->xr >= n->xr;) {
      n = erase(n);
      m->isect(*n);
    }
    if (m == begin() && m->xr == -INF) {
      erase(m);
    }
  }
  long long query(int x) {
    cmp = 1;
    Line l = *lower_bound((Line){0, 0, x});
    cmp = 0;
    return 1LL * l.k * x + l.b;
  }
  void display() {
    printf("Lower Convex Hull:\n");
    for (Line l : *this) {
      l.display();
    }
    printf("over\n");
  }
};
struct Edge {
  int ed, nxt;
};
const int maxn = 1e5 + 10;
int n, cnt;
LowConvHull lch;
int a[maxn], b[maxn], hed[maxn], sz[maxn];
long long dp[maxn];
Edge e[maxn << 1];
inline void addEdge(int u, int v) {
  e[cnt].ed = v;
  e[cnt].nxt = hed[u];
  hed[u] = cnt++;
}
void DFS1(int u, int p) {
  int i, v;
  sz[u] = 1;
  for (i = hed[u]; i != -1; i = e[i].nxt) {
    v = e[i].ed;
    if (v == p) {
      continue;
    }
    DFS1(v, u);
    sz[u] += sz[v];
  }
}
void DFS2(int u, int p, LowConvHull &lch) {
  int i, v, maxt = 0;
  LowConvHull tlch;
  for (i = hed[u]; i != -1; i = e[i].nxt) {
    v = e[i].ed;
    if (v != p && sz[v] > sz[maxt]) {
      maxt = v;
    }
  }
  if (sz[u] == 1) {
    dp[u] = 0;
  } else {
    DFS2(maxt, u, lch);
    for (i = hed[u]; i != -1; i = e[i].nxt) {
      v = e[i].ed;
      if (v == p || v == maxt) {
        continue;
      }
      tlch.clear();
      DFS2(v, u, tlch);
      for (Line l : tlch) {
        lch.ins((Line){l.k, l.b, -INF});
      }
    }
    dp[u] = -lch.query(a[u]);
  }
  lch.ins((Line){-b[u], -dp[u], -INF});
}
int main() {
  int i, j, k, u, v;
  scanf("%d", &n);
  for (i = (1); i <= (n); i++) {
    scanf("%d", &a[i]);
  }
  for (i = (1); i <= (n); i++) {
    scanf("%d", &b[i]);
  }
  memset(hed, -1, sizeof(hed));
  for (i = (1); i <= (n - 1); i++) {
    scanf("%d%d", &u, &v);
    addEdge(u, v);
    addEdge(v, u);
  }
  DFS1(1, 0);
  DFS2(1, 0, lch);
  for (i = (1); i <= (n - 1); i++) {
    printf("%I64d ", dp[i]);
  }
  printf("%I64d\n", dp[n]);
  return 0;
}
