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