#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T& a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T& a, T b) {
  return a < b ? (a = b, true) : false;
}
const long long inf = 1e18;
const int C = 1e5, N = 1e5 + 5;
struct Line {
  int k;
  long long b;
  Line(int k, long long b) : k(k), b(b) {}
};
long long f(const Line& line, int x) { return 1ll * line.k * x + line.b; }
struct Node {
  Node *lc, *rc;
  Line line;
  Node(const Line& line) : lc(NULL), rc(NULL), line(line) {}
};
int a[N], b[N];
long long dp[N];
vector<int> e[N];
Node* rt[N];
void modify(Node*& p, int l, int r, Line line) {
  if (p == NULL) {
    p = new Node(line);
    return;
  }
  int m = l + r >> 1;
  bool le = f(p->line, l) < f(line, l);
  bool mi = f(p->line, m) < f(line, m);
  if (!mi) swap(p->line, line);
  if (r - l == 1) return;
  if (le != mi)
    modify(p->lc, l, m, line);
  else
    modify(p->rc, m, r, line);
}
Node* merge(Node* p, Node* q, int l, int r) {
  if (p == NULL) return q;
  if (q == NULL) return p;
  int m = l + r >> 1;
  p->lc = merge(p->lc, q->lc, l, m);
  p->rc = merge(p->rc, q->rc, m, r);
  modify(p, l, r, q->line);
  return p;
}
long long qry(Node* p, int l, int r, int x) {
  if (p == NULL) return inf;
  long long ans = f(p->line, x);
  if (r - l == 1) return ans;
  int m = l + r >> 1;
  if (x < m)
    return min(ans, qry(p->lc, l, m, x));
  else
    return min(ans, qry(p->rc, m, r, x));
}
void dfs(int u, int p) {
  if ((int)(e[u]).size()) {
    for (auto&(v) : (e[u])) {
      e[v].erase(find((e[v]).begin(), (e[v]).end(), u));
      dfs(v, u);
      rt[u] = merge(rt[u], rt[v], -C, C + 1);
    }
    dp[u] = qry(rt[u], -C, C + 1, a[u]);
  }
  modify(rt[u], -C, C + 1, Line(b[u], dp[u]));
}
int main(int argc, char** argv) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  for (int i = 0; i < (int)(n); ++i) cin >> b[i];
  for (int i = 0; i < (int)(n - 1); ++i) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(0, -1);
  for (int i = 0; i < (int)(n); ++i) cout << dp[i] << " \n"[i == n - 1];
}
