#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) cout<<i<<" ";puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
	ll x=0,f=1;char c=getchar();
	while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if (c=='-') f=-1,c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}

const int N = 55, mod = 1e9+7;
int n,m;
bool flag[N][N];
poly e[N][N];

inline int Mod(int x){
	return x>=mod?x-mod:x;
}
inline void upd(int &x,int y){
	x=Mod(x+y);
}

int la,ra,a[N<<2],lb,rb,b[N<<2],f[2][2][N][N][N<<1];
inline void Get1(){
	For(i,1,n) For(j,1,n) if (siz(e[i][j])){
		la=N<<1,ra=la+1,a[la]=i,a[la+1]=j;
		lb=N<<1,rb=lb-1;
		for (auto k:e[i][j]) b[++rb]=k;
		int posl=0,posr=0;
		FOR(k,lb,rb) if (b[k]==i&&b[k+1]==j){
			posl=k,posr=k+1;break;
		} 
		if (!posl) continue;
		bool can=1;
		while (233){
			if (ra-la==rb-lb) break;
			Dow(i,posl-1,lb){
				int u=b[i],v=b[i+1];
				if (!flag[u][v]){can=0;break;}
				a[--la]=u,--posl;
				if (rb-lb+1+siz(e[u][v])>2*n+1){can=0;break;}
				Dow(j,siz(e[u][v])-1,0) b[--lb]=e[u][v][j];
			} 
			if (!can) break;
			FOR(i,posr,rb){
				int u=b[i],v=b[i+1];
				if (!flag[u][v]){can=0;break;}
				a[++ra]=v,++posr;
				if (rb-lb+1+siz(e[u][v])>2*n+1){can=0;break;}
				for (auto j:e[u][v]) b[++rb]=j;
			}
			if (!can) break;
		}
		if (can){
			f[1][1][a[la]][a[ra]][ra-la+1]++;
			//printf("cnm 1 %d %d %d %d\n",i,j,a[la],a[ra]);
			For(k,1,n) if (flag[k][a[la]]&&!siz(e[k][a[la]])){
				f[0][1][k][a[ra]][ra-la+1]++;
			}
		}
	}
}

inline void Get2(){
	For(i,1,n) For(j,1,n) if (siz(e[i][j])&&e[i][j][0]==j){
		la=N<<1,ra=la,a[la]=j;
		lb=N<<1,rb=lb-1;
		for (auto k:e[i][j]) b[++rb]=k;
		int pos=lb;
		bool can=1;
		while (233){
			if (ra-la==rb-lb) break;
			FOR(i,pos,rb){
				int u=b[i],v=b[i+1];
				if (!flag[u][v]){can=0;break;}
				a[++ra]=v,++pos;
				if (rb-lb+1+siz(e[u][v])>2*n+1){can=0;break;}
				for (auto j:e[u][v]) b[++rb]=j;
			}
			if (!can) break;
		}
		if (can) f[0][1][i][a[ra]][ra-la+1]++;//,printf("cnm 2 %d %d %d %d\n",i,j,a[ra],ra-la+1);
	}
}

inline void Get3(){
	For(i,1,n) For(j,1,n) if (siz(e[i][j])&&e[i][j].back()==i){
		la=N<<1,ra=la,a[la]=i;
		lb=N<<1,rb=lb-1;
		for (auto k:e[i][j]) b[++rb]=k;
		int pos=rb;
		bool can=1;
		while (233){
			if (ra-la==rb-lb) break;
			Dow(i,pos,lb+1){
				int u=b[i-1],v=b[i];
				if (!flag[u][v]){can=0;break;}
				a[--la]=v,--pos;
				if (rb-lb+1+siz(e[u][v])>2*n+1){can=0;break;}
				Dow(j,siz(e[u][v])-1,0) b[--lb]=e[u][v][j];
			}
			if (!can) break;
		}
		if (can){
			f[1][0][a[la]][j][ra-la+1]++;//,printf("cnm 3 %d %d %d\n",a[la],j,ra-la+1);
			For(k,1,n) if (flag[k][a[la]]&&!siz(e[k][a[la]])){
				f[0][0][k][j][ra-la+1]++;
			}
		}
	}
}

int dp[N<<1][N][2];
inline void DP(){
	For(i,1,2*n+1) For(j,1,n) For(k,1,n) upd(dp[i][k][0],f[1][0][j][k][i]),upd(dp[i][k][1],f[1][1][j][k][i]);
	For(i,1,2*n+1){
		For(_i,1,i) For(j,1,n) For(k,1,n) For(a,0,1) For(b,0,1) if (f[a][b][j][k][_i]){
			dp[i][k][b]=(dp[i][k][b]+1ll*dp[i-_i][j][a^1]*f[a][b][j][k][_i])%mod;
		}
	}
}

int main(){
	n=read(),m=read();
	For(i,1,m){
		int x=read(),y=read(),z=read();
		flag[x][y]=1;
		For(i,1,z) e[x][y].pb(read());
		if (z>2*n+1){
			e[x][y].clear(),flag[x][y]=0;
		}
	}
	Get1(),Get2(),Get3();
	DP();
	For(i,2,(n<<1)+1){
		int ans=0;
		For(k,1,n) ans=Mod(ans+dp[i][k][1]);
		printf("%d\n",ans);
	}
}
