{
TASK:store
LANG:pascal
}
type children=array of longint;
     rooms=Record
       father:Longint;
       dist:Longint;
       storage:Longint;
       cc:Longint;
       child:children;
     End;
var room:Array [1..10000] of rooms;
    n,m,k,s,i,j,t,ans:Longint;
Begin
  ReadLn(n,m);
 For i:=1 to n do
 Begin
   Read(j,k);
   room[i].storage:=j;
   {Debug +}
   ans:=ans+room[i].storage;
   {Debug -}
  If k>0 then
   For t:=1 to k do
    Begin
      room[i].cc:=room[i].cc+1;
      SetLength(room[i].child,room[i].cc);
      Read(room[i].child[room[i].cc-1]);
      room[room[i].child[room[i].cc-1]].father:=i;
      room[room[i].child[room[i].cc-1]].dist:=room[i].dist+1;
    End;
 End;
  WriteLn(round(ans/2));
End.