#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<ctime>
using namespace std;
long long n;
long long squ[200000]={};
int main()
{
freopen("three_squirrels.in","r",stdin);
freopen("three_squirrels.out","w",stdout);
cin>>n;
if(n==0) {cout<<1<<endl;exit(0);}
squ[0]=1;
for(long long i=1;i<=n;i++)
{
long long woo;
cin>>woo;
for(long long j=1;j<=woo;j++)
{
long long xx;
cin>>xx;
squ[i]=(squ[i]+squ[xx])%(1000000000+7);
}
}
cout<<squ[n]<<endl;
//cout<<"The time has passed:"<<clock()<<" ms"<<endl;
return 0;
}