#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxm = 2e5 + 10;
const int maxn = 1e5 + 10;
const int N = 2e5 + 1;
int a[maxn], b[maxn], head[maxn];
int root[maxn];
struct node {
  int ls, rs, flag;
  long long b, k;
} tree[maxm * 15];
struct Edge {
  int v, nxt;
} ed[maxm];
int ecnt, cnt;
long long anss;
long long ans[maxm];
double cross(long long k1, long long b1, long long k2, long long b2) {
  double res = (1.0 * (b2 - b1)) / (1.0 * (k1 - k2));
  return res;
}
void update(int L, int R, long long B, long long K, int &rt) {
  int l = L - 1e5 - 1;
  int r = R - 1e5 - 1;
  if (!rt) {
    rt = ++cnt;
    tree[rt].b = B;
    tree[rt].k = K;
  } else {
    int mid = l + r >> 1;
    int MID = L + R >> 1;
    long long y1 = K * l + B, y2 = K * r + B, y3 = tree[rt].k * l + tree[rt].b,
              y4 = tree[rt].k * r + tree[rt].b;
    if (y1 >= y3 && y2 >= y4) return;
    if (y1 <= y3 && y2 <= y4) {
      tree[rt].b = B;
      tree[rt].k = K;
      return;
    }
    double xx = cross(K, B, tree[rt].k, tree[rt].b);
    if (y1 >= y3) {
      if (xx > mid)
        update(MID + 1, R, B, K, tree[rt].rs);
      else {
        update(L, MID, tree[rt].b, tree[rt].k, tree[rt].ls);
        tree[rt].b = B;
        tree[rt].k = K;
      }
    } else {
      if (xx <= mid)
        update(L, MID, B, K, tree[rt].ls);
      else {
        update(MID + 1, R, tree[rt].b, tree[rt].k, tree[rt].rs);
        tree[rt].b = B;
        tree[rt].k = K;
      }
    }
  }
}
void merge(int &a, int b, int L, int R) {
  int l = L - 1e5 - 1;
  int r = R - 1e5 - 1;
  int mid = l + r >> 1;
  int MID = L + R >> 1;
  if (!b) return;
  if (!a) {
    a = b;
    return;
  } else {
    long long y1 = tree[a].k * mid + tree[a].b,
              y2 = tree[b].k * mid + tree[b].b;
    long long y3 = tree[a].k * l + tree[a].b, y4 = tree[b].k * l + tree[b].b;
    long long y5 = tree[a].k * r + tree[a].b, y6 = tree[b].k * r + tree[b].b;
    if (y3 <= y4 && y5 <= y6)
      ;
    else if (y3 >= y4 && y5 >= y6) {
      tree[a].k = tree[b].k;
      tree[a].b = tree[b].b;
    } else if (y1 >= y2) {
      if (y3 >= y4) {
        update(MID + 1, R, tree[a].b, tree[a].k, tree[a].rs);
      } else
        update(L, MID, tree[a].b, tree[a].k, tree[a].ls);
      tree[a].k = tree[b].k;
      tree[a].b = tree[b].b;
    } else {
      if (y3 >= y4)
        update(L, MID, tree[b].b, tree[b].k, tree[a].ls);
      else
        update(MID + 1, R, tree[b].b, tree[b].k, tree[a].rs);
    }
  }
  merge(tree[a].ls, tree[b].ls, L, MID);
  merge(tree[a].rs, tree[b].rs, MID + 1, R);
}
void query(int rt, int L, int R, int pos) {
  int l = L - 1e5 - 1;
  int r = R - 1e5 - 1;
  if (rt) {
    anss = min(anss, tree[rt].k * pos + tree[rt].b);
  }
  if (l == r) return;
  int mid = l + r >> 1;
  int MID = L + R >> 1;
  if (pos <= mid)
    query(tree[rt].ls, L, MID, pos);
  else
    query(tree[rt].rs, MID + 1, R, pos);
}
void addedge(int u, int v) {
  ed[ecnt].v = v;
  ed[ecnt].nxt = head[u];
  head[u] = ecnt++;
}
void dfs(int u, int fa) {
  for (int i = head[u]; i != -1; i = ed[i].nxt) {
    int v = ed[i].v;
    if (v == fa) continue;
    dfs(v, u);
    merge(root[u], root[v], 1, N);
  }
  anss = 1e18;
  query(root[u], 1, N, a[u]);
  if (anss >= 1e17) anss = 0;
  ans[u] = anss;
  update(1, N, anss, b[u], root[u]);
}
int main() {
  int n;
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  dfs(1, 0);
  printf("%I64d", ans[1]);
  for (int i = 2; i <= n; i++) printf(" %I64d", ans[i]);
  printf("\n");
  return 0;
}
