#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int linecmpmethod = 0;
struct Line {
  long long a, b;
  mutable long long rx;
  Line(long long a, long long b) : a(a), b(b) {}
  Line(long long rx) : rx(rx) {}
};
bool operator<(const Line &u, const Line &v) {
  if (linecmpmethod == 0) return u.a > v.a;
  if (linecmpmethod == 1) return u.rx < v.rx;
  return false;
}
struct LowerEnvelop : multiset<Line> {
  long long divdwn(long long num, long long den) {
    return num >= 0 ? num / den : (num - den + 1) / den;
  }
  void calcrx(iterator v, iterator w) {
    if (w == end())
      v->rx = LLONG_MAX;
    else if (v->a == w->a)
      v->rx = v->b < w->b ? LLONG_MAX : LLONG_MIN;
    else
      v->rx = divdwn(w->b - v->b, v->a - w->a);
  }
  void add(Line l) {
    auto v = insert(l);
    while (true) {
      auto w = next(v);
      calcrx(v, w);
      if (w == end() || v->rx < w->rx) break;
      w = erase(w);
    }
    if (v != begin()) {
      auto u = prev(v);
      calcrx(u, v);
      if (!(u->rx < v->rx)) {
        v = erase(v);
        calcrx(u, v);
      }
      while (u != begin()) {
        auto t = prev(u);
        if (t->rx < u->rx) break;
        erase(u);
        u = t;
        calcrx(u, v);
      }
    }
  }
  long long query(long long x) {
    assert(!empty());
    linecmpmethod = 1;
    Line l = *lower_bound(Line(x));
    linecmpmethod = 0;
    return l.a * x + l.b;
  }
};
const int MAXN = 100000;
int n;
int a[MAXN];
int b[MAXN];
vector<int> adj[MAXN];
long long ans[MAXN];
LowerEnvelop env[MAXN];
int dfs(int at, int par) {
  int ret = at;
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par) continue;
    int oth = dfs(to, at);
    if (((int)(env[ret]).size()) < ((int)(env[oth]).size())) swap(ret, oth);
    for (auto it = env[oth].begin(); it != env[oth].end(); ++it)
      env[ret].add(*it);
  }
  ans[at] = ((int)(env[ret]).size()) == 0 ? 0 : env[ret].query(a[at]);
  env[ret].add(Line(b[at], ans[at]));
  return ret;
}
void solve() {
  for (int i = (0); i < (n); ++i) env[i].clear();
  dfs(0, -1);
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  for (int i = (0); i < (n); ++i) scanf("%d", &b[i]);
  for (int i = (0); i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  solve();
  for (int i = (0); i < (n); ++i) {
    if (i != 0) printf(" ");
    printf("%lld", ans[i]);
  }
  puts("");
}
long long bfans[MAXN];
long long bfdfs2(int at, int par, int rt) {
  long long ret = LLONG_MAX;
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par) continue;
    ret = min(ret, (long long)a[rt] * b[to] + bfans[to]);
    ret = min(ret, bfdfs2(to, at, rt));
  }
  return ret;
}
void bfdfs(int at, int par) {
  bool leaf = true;
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par) continue;
    leaf = false;
    bfdfs(to, at);
  }
  bfans[at] = leaf ? 0 : bfdfs2(at, par, at);
}
void bfsolve() { bfdfs(0, -1); }
void stress() {
  for (int rep = (0); rep < (1000); ++rep) {
    int mxval = 100;
    n = 10000;
    for (int i = (0); i < (n); ++i)
      a[i] = rand() % (2 * mxval + 1) - mxval,
      b[i] = rand() % (2 * mxval + 1) - mxval;
    for (int i = (0); i < (n); ++i) adj[i].clear();
    for (int y = (1); y < (n); ++y) {
      int x = rand() % y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    solve();
    bfsolve();
    bool ok = true;
    for (int i = (0); i < (n); ++i)
      if (ans[i] != bfans[i]) ok = false;
    if (ok) {
      printf(".");
      continue;
    }
    printf("err\n");
    printf("have:");
    for (int i = (0); i < (n); ++i) printf(" %lld", ans[i]);
    puts("");
    printf("want:");
    for (int i = (0); i < (n); ++i) printf(" %lld", bfans[i]);
    puts("");
    printf("%d\n", n);
    for (int i = (0); i < (n); ++i) {
      if (i != 0) printf(" ");
      printf("%d", a[i]);
    }
    puts("");
    for (int i = (0); i < (n); ++i) {
      if (i != 0) printf(" ");
      printf("%d", b[i]);
    }
    puts("");
    for (int at = (0); at < (n); ++at)
      for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
        int to = adj[at][i];
        if (to < at) printf("%d %d\n", to + 1, at + 1);
      }
    break;
  }
}
int main() {
  run();
  return 0;
}
