#include <bits/stdc++.h>
using namespace std;
int sgn(long long x) {
  if (x == 0) {
    return 0;
  }
  return x < 0 ? -1 : 1;
}
bool check(long long a, int b, long long c, int d) {
  if (b < 0) {
    a = -a;
    b = -b;
  }
  if (d < 0) {
    c = -c;
    d = -d;
  }
  if (sgn(a) != sgn(c)) {
    return sgn(a) < sgn(c);
  }
  if (a / b != c / d) {
    return a / b < c / d;
  }
  a %= b;
  c %= d;
  return a * d <= c * b;
}
const int N = 100010;
vector<int> a[4 * N];
vector<long long> b[4 * N];
const long long inf = 1e18;
long long get_min(int x, long long v) {
  if (a[x].empty()) {
    return inf;
  }
  int l = -1, r = (int)a[x].size() - 1;
  while (r - l > 1) {
    int s = (l + r) / 2;
    if (v * (a[x][s] - a[x][s + 1]) >= b[x][s + 1] - b[x][s]) {
      l = s;
    } else {
      r = s;
    }
  }
  return a[x][l + 1] * v + b[x][l + 1];
}
void add_line(int x, int na, long long nb) {
  int sz = (int)a[x].size();
  if (sz >= 1 && na == a[x][sz - 1]) {
    if (nb >= b[x][sz - 1]) {
      return;
    }
    a[x].pop_back();
    b[x].pop_back();
    --sz;
  }
  while (sz >= 2 &&
         check(nb - b[x][sz - 2], a[x][sz - 2] - na,
               b[x][sz - 1] - b[x][sz - 2], a[x][sz - 2] - a[x][sz - 1])) {
    a[x].pop_back();
    b[x].pop_back();
    --sz;
  }
  a[x].push_back(na);
  b[x].push_back(nb);
}
int bb[N];
long long f[N];
int ver[N];
bool was[4 * N];
void update(int x, int l, int r) {
  if (was[x]) {
    return;
  }
  was[x] = true;
  a[x].clear();
  b[x].clear();
  if (l == r) {
    add_line(x, bb[ver[l]], f[ver[l]]);
    return;
  }
  int s = (l + r) / 2;
  update(2 * x, l, s);
  update(2 * x + 1, s + 1, r);
  int sz_ll = (int)a[2 * x].size();
  int sz_rr = (int)a[2 * x + 1].size();
  int ll = 0;
  int rr = 0;
  while (ll < sz_ll && rr < sz_rr) {
    if (a[2 * x][ll] > a[2 * x + 1][rr]) {
      add_line(x, a[2 * x][ll], b[2 * x][ll]);
      ++ll;
    } else {
      add_line(x, a[2 * x + 1][rr], b[2 * x + 1][rr]);
      ++rr;
    }
  }
  while (ll < sz_ll) {
    add_line(x, a[2 * x][ll], b[2 * x][ll]);
    ++ll;
  }
  while (rr < sz_rr) {
    add_line(x, a[2 * x + 1][rr], b[2 * x + 1][rr]);
    ++rr;
  }
}
long long get(int x, int l, int r, int ql, int qr, int v) {
  if (r < ql || l > qr) {
    return inf;
  }
  if (l >= ql && r <= qr) {
    update(x, l, r);
    return get_min(x, v);
  }
  int s = (l + r) / 2;
  return min(get(2 * x, l, s, ql, qr, v), get(2 * x + 1, s + 1, r, ql, qr, v));
}
int n;
int ct;
int aa[N];
vector<int> g[N];
void dfs(int x, int pa) {
  ver[ct] = x;
  ++ct;
  int pos = ct;
  for (int y : g[x]) {
    if (y != pa) {
      dfs(y, x);
    }
  }
  if (x != 0 && (int)g[x].size() == 1) {
    f[x] = 0;
  } else {
    f[x] = get(1, 0, n - 1, pos, ct - 1, aa[x]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", aa + i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", bb + i);
  }
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  ct = 0;
  memset(was, false, sizeof was);
  dfs(0, -1);
  for (int i = 0; i < n; ++i) {
    printf("%lld ", f[i]);
  }
  putchar('\n');
}
