#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
#define inf 0x3f3f3f3f
int first[208],nxt[208],vv[208];
struct Island
{
int ned,ded;
}island[108];
struct Son
{
int ned,ded,red;
}sson[108][108];
inline int max(int a,int b)
{
return a>b?a:b;
}
inline int min(int a,int b)
{
return a>b?b:a;
}
int ned[208],ded[208],red[208];
bool vis[208];
bool cmp(Son a,Son b)
{
if(a.ned > b.ned) return 1;
if(a.ned < b.ned) return 0;
if(a.ned == b.ned) return a.ded < b.ded;
}
void dfs(int x)
{
int t = 0;
bool flag = false;
vis[x] = 1;
for(int i=first[x];i!=-1;i=nxt[i])
{
int v = vv[i];
if(!vis[v])
{
flag = true;
dfs(v);
sson[x][t].red = red[v];
sson[x][t].ded = ded[v];
sson[x][t++].ned = ned[v];
}
}
if(!flag)
{
ned[x] = island[x].ned;
ded[x] = island[x].ded;
red[x] = island[x].ned - island[x].ded;
return;
}
sort(sson[x],sson[x]+t,cmp);
int nedd = island[x].ned,dedd = island[x].ded,res = island[x].ned - island[x].ded;
for(int i=0;i<t;i++)
{
if(res < sson[x][i].ned)//如果剩下的人不够攻打
{
nedd += sson[x][i].ned - res;
res += sson[x][i].ned - res;
}
//现在够攻打了
if(res < sson[x][i].ded)//如果剩下的人不够占领该地
{
nedd += sson[x][i].ded - res;
res += sson[x][i].ded - res;
}
res -= sson[x][i].ded;
dedd += sson[x][i].ded;
}
ded[x] = dedd;
ned[x] = nedd;
}
int main()
{
///freopen("in.txt","r",stdin);
int n;
while(scanf("%d",&n)!=EOF)
{
int e = 0;
memset(first,-1,sizeof(first));
for(int i=1;i<=n;i++)
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
island[i].ned = max(a,b+c);
island[i].ded = b+c;
}
for(int i=1;i<n;i++)
{
int u,v;
scanf("%d%d",&u,&v);
nxt[e]=first[u],vv[e]=v,first[u]=e++;
nxt[e]=first[v],vv[e]=u,first[v]=e++;
}
int ans = inf;
for(int i=1;i<=n;i++)
{
memset(vis,0,sizeof(vis));
memset(ned,0,sizeof(ned));
memset(ded,0,sizeof(ded));
dfs(i);
ans = min(ans,ned[i]);
}
printf("%d\n",ans);
}
return 0;
}