#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m;
const long long a=1000000007;
long long ans[100001];
int x;
int main()
{
freopen("three_squirrels.in","r",stdin);
freopen("three_squirrels.out","w",stdout);
cin>>n;
ans[0]=1;
for(int i=1;i<=n;i++)
{
scanf("%d",&m);
for(int j=1;j<=m;j++)
{
scanf("%d",&x);
ans[i]+=ans[x]%a;
}
}
cout<<ans[n]<<endl;
return 0;
}