#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
#define int long long
using namespace std;
const int N = 1e5 + 10;
int p[N], sz[N], deg[N], a[N], b[N], order[N];
long long dist[20][N], f[N];
bool dd[N];
vector<pair<int, int> > adj[N];
struct line {
long long m, c;
long long eval(long long x) { return m * x + c; }
float cut(line l) {
return (float) (c - l.c) / (l.m - m);
}
};
struct CHT {
vector<line> st;
void add(line cur) {
if (!st.empty() && st.back().m == cur.m) {
if (st.back().c >= cur.c) return;
st.pop_back();
}
while (st.size() >= 2 && cur.cut(st.back()) <= st.back().cut(st.end()[-2])) st.pop_back();
st.push_back(cur);
}
long long get(long long x) {
if (st.empty()) return 1e18;
int l = 0, r = st.size() - 1;
while (l < r) {
int mid = l + r >> 1;
if (st[mid].eval(x) >= st[mid + 1].eval(x)) l = mid + 1;
else r = mid;
}
return st[r].eval(x);
}
} cht[N];
int calc(int u, int par) {
sz[u] = 1;
for(auto &[v, w] : adj[u]) if (v != par && !dd[v]) sz[u] += calc(v, u);
return sz[u];
}
int getcentr (int u, int par, int cnt) {
for(auto &[v, w] : adj[u]) if (v != par && !dd[v] && sz[v] * 2 > cnt) {
return getcentr (v, u, cnt);
}
return u;
}
void dfs(int u, int par, int j) {
for(auto &[v, w] : adj[u]) if (v != par && !dd[v]) {
dist[j][v] = dist[j][u] + w;
dfs(v, u, j);
}
}
void centroid(int u, int par) {
int node = getcentr(u, u, calc(u, u));
p[node] = par;
dd[node] = 1;
deg[node] = deg[par] + 1;
dfs(node, node, deg[node]);
for(auto &[v, w] : adj[node]) if (!dd[v]) centroid(v, node);
}
void add(int u) {
int v = u;
while (v) {
cht[v].add({b[u], f[u] + dist[deg[v]][u] * b[u] + a[u]});
v = p[v];
}
}
long long get(int u) {
int v = u;
long long ret = 1e18;
while (v) {
ret = min(ret, cht[v].get(dist[deg[v]][u]));
v = p[v];
}
return ret;
}
vector<long long> travel (vector<long long> A, vector<int> B, vector<int> U, vector<int> V, vector<int> W) {
int n = A.size();
for(int i = 1; i <= n; i++) a[i] = A[i - 1], b[i] = B[i - 1];
for(int i = 0; i < n - 1; i++) {
U[i]++;
V[i]++;
adj[U[i]].emplace_back(V[i], W[i]);
adj[V[i]].emplace_back(U[i], W[i]);
}
centroid(1, 0);
for(int i = 1; i <= n; i++) order[i] = i;
sort(order + 1, order + n + 1, [] (const int &x, const int &y) {
return b[x] > b[y];
});
int one = 0;
// for(int i = 1; i <= n; i++) cout << order[i] << " "; cout << endl;
for(int cur = 1; cur <= n; cur++) if (order[cur] == 1) one = cur;
assert(one);
add(1);
// cout << get(2);
// exit(0);
for(int cur = one + 1; cur <= n; cur++) {
int i = order[cur];
f[i] = get(i);
// cout << i << " " << f[i] << endl;
add(i);
}
// exit(0);
vector<long long> ret;
for(int i = 2; i <= n; i++) {
long long cost = get(i);
ret.push_back(cost);
}
return ret;
}
#ifdef ngu
int32_t main() {
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
int n;
cin >> n;
vector<long long> A(n);
vector<int> B(n), U(n - 1), V(n - 1), W(n - 1);
for(int i = 0; i < n; i++) cin >> A[i];
for(int i = 0; i < n; i++) cin >> B[i];
for(int i = 0; i < n - 1; i++) {
cin >> U[i] >> V[i] >> W[i];
}
vector<long long> ans = travel(A, B, U, V, W);
for(auto &x : ans) cout << x << " ";
// for (long long x : travel(A, B, U, V, W)) {
// cout << x << ' ';
// }
cout << '\n';
}
#endif // ngu