#include<stdio.h>
#include<vector>
#include<algorithm>
#define M 1000005
using namespace std;
int n;
long long a[M],W[M],F[M];
int b[M],st[M],tp;
struct Edge{
int x,w;
operator int() const{return x;}
};
vector<Edge> G[M];
struct Line{
long long k,b;
inline long long operator()(long long x) const{return k*x+b;}
};
struct SGT{
struct Node{
int ls,rs;Line s;
} tr[M<<5];
int tot;
void upd(int &x,long long l,long long r,Line u){
if(!x) return tr[x=++tot]={0,0,u},void();
Line &v=tr[x].s;long long mid=l+r>>1;
if(u(mid)<=v(mid)) swap(u,v);
long long ul=u(l),ur=u(r),vl=v(l),vr=v(r);
if(ul>=vl&&ur>=vr) return;
if(ul<=vl&&ur<=vr) return tr[x].s=u,void();
if(ul<=vl) upd(tr[x].ls,l,mid,u);
if(ur<=vr) upd(tr[x].rs,mid+1,r,u);
}
long long que(int x,long long l,long long r,long long k){
if(!x) return 0x7fffffffffffffff;
long long res=tr[x].s(k);
if(l==r) return res;
long long mid=l+r>>1;
if(k<=mid) res=min(res,que(tr[x].ls,l,mid,k));
if(k>mid) res=min(res,que(tr[x].rs,mid+1,r,k));
return res;
}
} sgt;
int sz[M],dep[M],top[M],big[M],f[M],rt[M],fa[M];
vector<int> H[M];
void dfs(int x,int fa){
sz[x]=1,dep[x]=dep[fa]+1,f[x]=fa;
for(auto [p,w]:G[x]) if(p!=fa)
W[p]=W[x]+w,dfs(p,x),
sz[x]+=sz[p],(sz[p]>sz[big[x]])&&(big[x]=p);
}
void ctp(int x,int tp){
top[x]=tp;
if(big[x]) ctp(big[x],tp);
for(int p:G[x]) if(p!=big[x]&&p!=f[x])
ctp(p,p);
}
int LCA(int x,int y){
while(top[x]!=top[y]){
if(dep[top[x]]>dep[top[y]]) x=f[top[x]];
else y=f[top[y]];
}
return dep[x]<dep[y]?x:y;
}
long long dis(int x,int y){return W[x]+W[y]-2*W[LCA(x,y)];}
namespace ASD{
int sz[M],all,mn,rt;
bool vis[M];
void frt(int x){
sz[x]=1,vis[x]=1;
int mx=0;
for(int p:G[x]) if(!vis[p])
frt(p),mx=max(mx,sz[p]),sz[x]+=sz[p];
mx=max(mx,all-sz[x]);
if(mx<mn) mn=mx,rt=x;
vis[x]=0;
}
void dfs(int x){
vis[x]=1,sz[x]=1;
for(int p:G[x]) if(!vis[p])
dfs(p),sz[x]+=sz[p];
vis[x]=0;
}
int div(int x){
mn=0x7fffffff,frt(x),x=rt,vis[x]=1;
for(int p:G[x]) if(!vis[p])
dfs(p),all=sz[p],H[x].push_back(div(p));
return x;
}
void work(){all=n,div(1);}
}
inline void cal(int x){
F[x]=0x7fffffffffffffff;
for(int t=x;t;t=fa[t]) F[x]=min(F[x],sgt.que(rt[t],1,1e12,dis(x,t)));
}
inline void ins(int x){
for(int t=x;t;t=fa[t]) sgt.upd(rt[t],1,1e12,Line{b[x],b[x]*dis(x,t)+a[x]+F[x]});
}
vector<long long> travel(vector<long long> A,vector<int> B,vector<int> U,vector<int> V,vector<int> W){
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],
G[U[i]].push_back({V[i],W[i]}),
G[V[i]].push_back({U[i],W[i]});
}
dfs(1,0),ctp(1,1);
ASD::work();
for(int i=1;i<=n;++i) for(int p:H[i]) fa[p]=i;
for(int i=1;i<=n;++i) st[i]=i;
sort(st+1,st+n+1,[](int x,int y){return b[x]<b[y];}),tp=n;
while(st[tp]!=1) --tp;
while(tp){
int x=st[tp--];
if(x!=1) cal(x);
ins(x);
}
for(int i=2;i<=n;++i) cal(i);
return vector<long long>(F+2,F+n+1);
}
#include <cstdio>
#include <cstdlib>
#include <vector>
void my_assert(bool p, int cs)
{
if(!p)
{
if(cs == 1) puts("Wrong input");
if(cs == 2) puts("Length of array should be N-1");
exit(0);
}
}
int main()
{
freopen("D2.in","r",stdin);
int n;
my_assert(scanf("%d", &n) == 1, 1);
std::vector<long long> A(n);
std::vector<int> B(n), U(n - 1), V(n - 1), W(n - 1);
for(int i = 0; i < n; ++i) my_assert(scanf("%lld", &A[i]) == 1, 1);
for(int i = 0; i < n; ++i) my_assert(scanf("%d", &B[i]) == 1, 1);
for(int i = 0; i < n - 1; ++i) my_assert(scanf("%d%d%d", &U[i], &V[i], &W[i]) == 3, 1);
std::vector<long long> ans = travel(A, B, U, V, W);
my_assert((int)ans.size() == n - 1, 2);
for(int i = 0; i < n - 1; ++i) printf("%lld\n", ans[i]);
return 0;
}