#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
const long long MAXN = 2e5 + 10;
const long long INF = 1e18 + 10;
const long long mod = 1e9 + 7;
const long double eps = 1e-5;
using namespace std;
int n;
long long a[100001];
long long b[100001];
long long dp[100001];
vector<pair<long long, long long>> emp;
vector<int> g[100001];
long double inter(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second - b.second == 0) return INF;
  return (1.0 * b.first - a.first) / (1.0 * a.second - b.second);
}
void add(vector<pair<long long, long long>> &c, pair<long long, long long> a) {
  while (c.size() > 1) {
    pair<long long, long long> l = c.back();
    if (a.second == l.second) {
      if (a.first < l.first) {
        c.pop_back();
        continue;
      } else
        return;
    }
    pair<long long, long long> t = c[c.size() - 2];
    long double p1 = inter(l, a);
    long double p2 = inter(t, l);
    if (p2 - p1 > eps)
      c.pop_back();
    else
      break;
  }
  if (c.size() == 1) {
    if (a.second == c.back().second && a.first < c.back().first) c.pop_back();
  }
  c.push_back(a);
}
vector<pair<long long, long long>> merging(
    vector<pair<long long, long long>> &a,
    vector<pair<long long, long long>> &b) {
  if (!a.size()) return b;
  if (!b.size()) return a;
  vector<pair<long long, long long>> c;
  int i = 0;
  int j = 0;
  while (i < a.size() || j < b.size()) {
    if (i == a.size()) {
      add(c, b[j]);
      j++;
    } else if (j == b.size()) {
      add(c, a[i]);
      i++;
    } else if (a[i].second > b[j].second ||
               (a[i].second == b[j].second && a[i].first > b[j].first)) {
      add(c, a[i]);
      i++;
    } else {
      add(c, b[j]);
      j++;
    }
  }
  return c;
}
void merge(vector<vector<pair<long long, long long>>> &a,
           vector<vector<pair<long long, long long>>> &b) {
  vector<pair<long long, long long>> add;
  for (int i = 0; i < max(a.size(), b.size()) || add.size(); i++) {
    if (i == a.size()) a.push_back(emp);
    int t = (a[i].size() > 0) + (add.size() > 0) +
            (i < b.size() ? (b[i].size() > 0) : 0);
    if (!t)
      continue;
    else if (t == 1) {
      a[i] = (a[i].size() > 0 ? a[i] : (add.size() > 0 ? add : b[i]));
      add.clear();
    } else if (t == 2) {
      add = (!add.size()
                 ? merging(a[i], b[i])
                 : (!a[i].size() ? merging(b[i], add) : merging(a[i], add)));
      a[i] = emp;
    } else {
      add = merging(add, b[i]);
    }
  }
}
long long query(vector<pair<long long, long long>> c, long long x) {
  if (!c.size()) return INF;
  int l = 0;
  int r = (int)c.size() - 1;
  while (l < r) {
    int m = (l + r) / 2;
    long double tr = (m == (int)c.size() - 1 ? INF : inter(c[m], c[m + 1]));
    if (x - tr > eps)
      l = m + 1;
    else
      r = m;
  }
  return c[l].first + c[l].second * x;
}
void dfs(int v, int p, vector<vector<pair<long long, long long>>> &cv) {
  vector<vector<pair<long long, long long>>> cto;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to != p) {
      dfs(to, v, cto);
      merge(cv, cto);
      cto.clear();
    }
  }
  for (int i = 0; i < cv.size(); i++) dp[v] = min(dp[v], query(cv[i], a[v]));
  if (!cv.size()) dp[v] = 0;
  vector<pair<long long, long long>> t = {{dp[v], b[v]}};
  vector<vector<pair<long long, long long>>> q;
  q.push_back(t);
  merge(cv, q);
  return;
}
void solve(int tt) {
  cin >> n;
  for (int i = 1; i <= n; i++) dp[i] = INF;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int j = 1; j <= n; j++) {
    cin >> b[j];
  }
  for (int i = 0; i + 1 < n; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<vector<pair<long long, long long>>> q;
  dfs(1, -1, q);
  for (int i = 1; i <= n; i++) cout << dp[i] << " ";
}
int main() {
  srand(time(NULL));
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  for (int i = 0; i < t; i++) solve(i + 1);
  return 0;
}
