#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
const long long maxn=1000000007;
int n,ki;
long long f[100010];
int main()
{
freopen("three_squirrels.in","r",stdin);
freopen("three_squirrels.out","w",stdout);
memset(f,0,sizeof(f));
f[0]=1;
cin>>n;
for(int i=1;i<=n;i++)
{
int m;
cin>>m;
for(int j=1;j<=m;j++)
{
int q;
cin>>q;
f[i]=(f[i]+f[q])%maxn;
}
}
cout<<f[n]<<endl;
fclose(stdin);
fclose(stdout);
return 0;
}