#include<bits/stdc++.h>
using namespace std;
#define re register int
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
#define I inline void
#define IN inline int
#define C(x,y) memset(x,y,sizeof(x))
#define STS system("pause")
template<class D>I read(D &res){
	res=0;register D g=1;register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
const int Mod=1e9+7;
I add(int &x,int y){(x+=y)>=Mod?x-=Mod:0;}
IN Plus(int x,int y){(x+=y)>=Mod?x-=Mod:0;return x;}
vector<int>vec[2020];
int n,m,flg,ans[110],u[2020],v[2020],sz[2020],f[110][110][110][4],g[110][110][2],c[60][60];
int a[110],b[110],d[110],cd,ca,cb,sn,now;
int main(){
//	freopen("path.in","r",stdin);
//	freopen("path.out","w",stdout);
	read(n);read(m);flg=0;
	F(i,1,m){
		re w;
		read(u[i]);read(v[i]);read(sz[i]);
		vec[i].resize(sz[i]);
		F(j,0,sz[i]-1)read(w),vec[i][j]=w;
//		add(u[i],v[i],i);
		c[u[i]][v[i]]=i;
	}
//	cout<<"!!!!";
	F(cur,1,m){
//		cout<<"!";
		re x=u[cur],y=v[cur],cnt=0,p;
		if(sz[cur]>1)F(i,0,sz[cur]-2)if(vec[cur][i]==x&&vec[cur][i+1]==y)cnt++;
		if(cnt==1){
			F(i,0,sz[cur]-2)if(vec[cur][i]==x&&vec[cur][i+1]==y){
//				cout<<"!"<<cur<<" "<<i<<":"<<endl;
				ca=0;FOR(j,i,0)a[++ca]=vec[cur][j];now=1;sn=1;
				while(now<ca){
					if(!c[a[now+1]][a[now]]||ca-1>(n<<1)){sn=0;break;}
					FOR(i,sz[c[a[now+1]][a[now]]]-1,0)p=vec[c[a[now+1]][a[now]]][i],a[++ca]=p;
					now++;
				}
//				cout<<ca<<" ";F(i,1,ca)cout<<a[i]<<" ";cout<<endl;
				if(!sn)continue;
//				cout<<"B"<<endl;
				cb=0;F(j,i+1,sz[cur]-1)b[++cb]=vec[cur][j];now=sn=1;
				while(now<cb){
					if(!c[b[now]][b[now+1]]||cb-1>(n<<1)){sn=0;break;}
					for(auto p:vec[c[b[now]][b[now+1]]])b[++cb]=p;
					now++;
				}
//				cout<<cb<<" ";F(i,1,cb)cout<<b[i]<<" ";cout<<endl;
				if(!sn||ca+cb-1>(n<<1))continue;
//				cout<<"C"<<endl;
//				if(!flg){
//					printf("%d\n",ca+cb);
//					FOR(j,ca,1)printf("%d ",a[j]);
//					F(j,1,cb)printf("%d ",b[j]);
//					printf("\n");flg=1;
//				}
//				cout<<"! 1"<<endl;
//				FOR(i,ca,1)printf("%d ",a[i]);
//				F(i,1,cb)printf("%d ",b[i]);
//				printf("\n");
				f[a[ca]][b[cb]][ca+cb-1][1]++;g[ca+cb-1][b[cb]][1]++;
			}
		}
		if(!sz[cur])f[x][y][1][3]++;//,cout<<"! 3"<<" "<<x<<" "<<y<<endl;
		else{
			if(vec[cur][sz[cur]-1]==x){
				cd=0;FOR(i,sz[cur]-1,0)d[++cd]=vec[cur][i];now=sn=1;
				while(now<cd){
					if(!c[d[now+1]][d[now]]||cd>(n<<1)){sn=0;break;}
					FOR(i,sz[c[d[now+1]][d[now]]]-1,0)p=vec[c[d[now+1]][d[now]]][i],d[++cd]=p;
					now++;
				}
				if(sn){
					f[d[cd]][y][cd][0]++;g[cd][y][0]++;
//					cout<<"! 0"<<endl;
//					FOR(i,cd,1)cout<<d[i]<<" ";cout<<endl;
				}
			}
			if(vec[cur][0]==y){
				cd=0;F(i,0,sz[cur]-1)d[++cd]=vec[cur][i];now=sn=1;
				while(now<cd){
					if(!c[d[now]][d[now+1]]||cd>(n<<1)){sn=0;break;}
					if(sz[c[d[now]][d[now+1]]])for(auto p:vec[c[d[now]][d[now+1]]])d[++cd]=p;
					now++;
				}
				if(sn){
					f[x][d[cd]][cd][2]++;
//					cout<<"! 2"<<endl;
//					F(i,1,cd)cout<<d[i]<<" ";
//					cout<<endl;
				}
			}
		}
	}
	if(!flg)printf("0\n\n");
	F(i,1,n<<1)F(x,1,n){
		if(g[i][x][0]){
			F(k,1,(n<<1)-i)F(y,1,n){
				if(f[x][y][k][0])add(g[i+k][y][0],(ll)g[i][x][0]*f[x][y][k][0]%Mod);
				if(f[x][y][k][1])add(g[i+k][y][1],(ll)g[i][x][0]*f[x][y][k][1]%Mod);
			}
		}
		if(g[i][x][1]){
			F(k,1,(n<<1)-i)F(y,1,n){
				if(f[x][y][k][2])add(g[i+k][y][1],(ll)g[i][x][1]*f[x][y][k][2]%Mod);
				if(f[x][y][k][3])add(g[i+k][y][0],(ll)g[i][x][1]*f[x][y][k][3]%Mod);
			}
			add(ans[i],g[i][x][1]);
		}
	}
//	F(i,1,n<<1)F(j,1,n)add(ans[i],g[i][j][1]);
	F(i,1,n<<1)printf("%d\n",ans[i]);
	return 0;
}
/*
5 7
3 2 1 2
1 3 3 5 1 3
2 4 2 2 5
2 5 3 4 2 1
5 1 0
4 5 1 4
3 4 1 4
*/
