#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
#define ll long long
const int MAXN=200010;
using namespace std;
ll pu[MAXN],mo[MAXN],n,num=0,tot=0,dp[MAXN],have[MAXN];
vector<ll> shang[MAXN];queue<ll>q;
struct edge{
int first;
int next;
int to;
}a[10*MAXN];
void addedge(int from,int to){
a[++num].to=to;
a[num].next=a[from].first;
a[from].first=num;
}
void cl(){
memset(pu,0,sizeof(pu));
memset(dp,37,sizeof(dp));
}
void spfa(){
for(int i=1;i<=n;i++){
have[i]=1;q.push(i);dp[i]=mo[i];
}
while(!q.empty()){
ll now=q.front(),sum=pu[now],len;
q.pop();
have[now]=0;
for(int i=a[now].first;i;i=a[i].next){
int to=a[i].to;
sum+=dp[to];
}
if(dp[now]>sum){
dp[now]=sum,len=shang[now].size();
for(int i=0;i<len;i++){
if(!have[shang[now][i]]){
have[shang[now][i]]=1;
q.push(shang[now][i]);
}
}
}
}
}
int main(){
cl();
scanf("%d",&n);
for(ll i=1;i<=n;i++){
ll x,y,z;
scanf("%lld%lld%lld",&x,&y,&z);
pu[i]=x,mo[i]=y;
for(ll j=1;j<=z;j++){
ll k;scanf("%lld",&k);
addedge(i,k);
shang[k].push_back(i);
}
}
spfa();
printf("%lld",dp[1]);
}