#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
vector<pa> a[200010];
vector<int> M[2][2];
int n,m,k,x,y,top,D,tmp[4],tag,bl,F[200010],g[200010],stk[200010],G[200010][2],tp,d[200010],f[200010][2][2];
bool v[200010],flag;
void find(int x){
	v[x]=1;
	stk[++top]=x;
	for (int i=0;i<a[x].size();++i){
		int y=a[x][i].fi;
		if (!v[y]) find(y);
	}
}
void chain(){
	FOR(i,1,top) v[stk[i]]=0;
	FOR(i,1,top)
		if (d[stk[i]]==1 || top==1) D=stk[i];
	top=0;
	find(D);
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][0]]=1;
	f[1][1][G[stk[1]][1]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	F[0]=F[1]=0;
	FOR(l,0,1)
		FOR(p,0,1)
			(F[p]+=f[top][l][p])%=MO;
	LL x=g[0],y=g[1];
	g[0]=(x*F[0]+y*F[1])%MO;
	g[1]=(x*F[1]+y*F[0])%MO;
}
void circle(){
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][0]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
	for (int i=0;i<a[stk[top]].size();++i)
		if (a[stk[top]][i].fi==stk[1]){
			tmp[a[stk[top]][i].se]^=1;
		}
	F[0]=F[1]=0;
	FOR(l,0,1)
		FOR(p,0,1){
			int s=0;
			for (int L=0;L<M[l][0].size();++L)
				s^=tmp[M[l][0][L]];
			(F[p^s]+=f[top][l][p])%=MO;
		}
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][1]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
	for (int i=0;i<a[stk[top]].size();++i)
		if (a[stk[top]][i].fi==stk[1]){
			tmp[a[stk[top]][i].se]^=1;
		}
	FOR(l,0,1)
		FOR(p,0,1){
			int s=0;
			for (int L=0;L<M[l][1].size();++L)
				s^=tmp[M[l][1][L]];
			(F[p^s]+=f[top][l][p])%=MO;
		}

	LL x=g[0],y=g[1];
	g[0]=(x*F[0]+y*F[1])%MO;
	g[1]=(x*F[1]+y*F[0])%MO;
}
int main(){
	scanf("%d%d",&n,&m);
	FOR(i,1,n){
		getint(k);
		if (k==2){
			getint(x),getint(y);
			if (abs(x)==abs(y)){
				if (x==y && x>0) G[x][1]^=1;
				else if (x==y && x<0) G[x][0]^=1;
				else tag^=1;
				continue;
			}
			flag=0;
			if (lower_bound(a[abs(x)].begin(),a[abs(x)].end(),mp(abs(y),0))!=a[abs(x)].end()){
				if ((*lower_bound(a[abs(x)].begin(),a[abs(x)].end(),mp(abs(y),0))).fi==abs(y)) flag=1;
			}
			if (!flag) d[abs(x)]++,d[abs(y)]++;
			if (x<0 && y<0) tp=1;
			else if (x<0 && y>0) tp=2;
			else if (x>0 && y<0) tp=3;
			else tp=0;
			a[abs(x)].pb(mp(abs(y),tp));
			swap(x,y);
			if (x<0 && y<0) tp=1;
			else if (x<0 && y>0) tp=2;
			else if (x>0 && y<0) tp=3;
			else tp=0;
			a[abs(x)].pb(mp(abs(y),tp));
		}
		else{
			getint(x);
			if (x>0) G[x][1]^=1;
			else G[x][0]^=1;
		}
	}
	M[0][0].pb(1),M[0][0].pb(2),M[0][0].pb(3);
	M[0][1].pb(2),M[0][1].pb(1),M[0][1].pb(0);
	M[1][0].pb(0),M[1][0].pb(3),M[1][0].pb(1);
	M[1][1].pb(0),M[1][1].pb(2),M[1][1].pb(3);
	g[0]=1;
	FOR(i,1,m)
		if (!v[i]){
			top=0;
			++bl;
			find(i);
			flag=0;
			FOR(j,1,top)
				if (d[stk[j]]==1) flag=1;
			if (flag || top<3) chain();
			else circle();
		}
	cout<<g[1^tag]<<endl;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
vector<pa> a[200010];
vector<int> M[2][2];
int n,m,k,x,y,top,D,tmp[4],tag,bl,F[200010],g[200010],stk[200010],G[200010][2],tp,d[200010],f[200010][2][2];
bool v[200010],flag;
void find(int x){
	v[x]=1;
	stk[++top]=x;
	for (int i=0;i<a[x].size();++i){
		int y=a[x][i].fi;
		if (!v[y]) find(y);
	}
}
void chain(){
	FOR(i,1,top) v[stk[i]]=0;
	FOR(i,1,top)
		if (d[stk[i]]==1 || top==1) D=stk[i];
	top=0;
	find(D);
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][0]]=1;
	f[1][1][G[stk[1]][1]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	F[0]=F[1]=0;
	FOR(l,0,1)
		FOR(p,0,1)
			(F[p]+=f[top][l][p])%=MO;
	LL x=g[0],y=g[1];
	g[0]=(x*F[0]+y*F[1])%MO;
	g[1]=(x*F[1]+y*F[0])%MO;
}
void circle(){
	FOR(i,1,top) v[stk[i]]=0;
	FOR(i,1,top)
		if (d[stk[i]]==1) D=stk[i];
	top=0;
	find(D);
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][0]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
	for (int i=0;i<a[stk[top]].size();++i)
		if (a[stk[top]][i].fi==stk[1]){
			tmp[a[stk[top]][i].se]^=1;
		}
	F[0]=F[1]=0;
	FOR(l,0,1)
		FOR(p,0,1)
			if (top>2){
				int s=0;
				for (int L=0;L<M[l][0].size();++L)
					s^=M[l][0][L];
				(F[p^s]+=f[top][l][p])%=MO;
			}
			else (F[p]+=f[top][l][p])%=MO;
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][1]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
	for (int i=0;i<a[stk[top]].size();++i)
		if (a[stk[top]][i].fi==stk[1]){
			tmp[a[stk[top]][i].se]^=1;
		}
	FOR(l,0,1)
		FOR(p,0,1)
			if (top>2){
				int s=0;
				for (int L=0;L<M[l][1].size();++L)
					s^=M[l][1][L];
				(F[p^s]+=f[top][l][p])%=MO;
			}
			else (F[p]+=f[top][l][p])%=MO;

	LL x=g[0],y=g[1];
	g[0]=(x*F[0]+y*F[1])%MO;
	g[1]=(x*F[1]+y*F[0])%MO;
}
int main(){
	scanf("%d%d",&n,&m);
	FOR(i,1,n){
		getint(k);
		if (k==2){
			getint(x),getint(y);
			if (abs(x)==abs(y)){
				if (x==y && x>0) G[x][1]^=1;
				else if (x==y && x<0) G[x][0]^=1;
				else tag^=1;
				continue;
			}
			flag=0;
			if (lower_bound(a[abs(x)].begin(),a[abs(x)].end(),mp(abs(y),0))!=a[abs(x)].end()){
				if ((*lower_bound(a[abs(x)].begin(),a[abs(x)].end(),mp(abs(y),0))).fi==abs(y)) flag=1;
			}
			if (!flag) d[abs(x)]++,d[abs(y)]++;
			if (x<0 && y<0) tp=1;
			else if (x<0 && y>0) tp=2;
			else if (x>0 && y<0) tp=3;
			else tp=0;
			a[abs(x)].pb(mp(abs(y),tp));
			swap(x,y);
			if (x<0 && y<0) tp=1;
			else if (x<0 && y>0) tp=2;
			else if (x>0 && y<0) tp=3;
			else tp=0;
			a[abs(x)].pb(mp(abs(y),tp));
		}
		else{
			getint(x);
			if (x>0) G[x][1]^=1;
			else G[x][0]^=1;
		}
	}
	M[0][0].pb(1),M[0][0].pb(2),M[0][0].pb(3);
	M[0][1].pb(2),M[0][1].pb(1),M[0][1].pb(0);
	M[1][0].pb(0),M[1][0].pb(3),M[1][0].pb(1);
	M[1][1].pb(0),M[1][1].pb(2),M[1][1].pb(3);
	g[0]=1;
	FOR(i,1,m)
		if (!v[i]){
			top=0;
			++bl;
			find(i);
			flag=0;
			FOR(j,1,top)
				if (d[stk[j]]==1) flag=1;
			if (flag || top<3) chain();
			else circle();
		}
	cout<<g[1^tag]<<endl;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
vector<pa> a[200010];
vector<int> M[2][2];
int n,m,k,x,y,top,D,tmp[4],tag,bl,F[200010],g[200010],stk[200010],G[200010][2],tp,d[200010],f[200010][2][2];
bool v[200010],flag;
void find(int x){
	v[x]=1;
	stk[++top]=x;
	for (int i=0;i<a[x].size();++i){
		int y=a[x][i].fi;
		if (!v[y]) find(y);
	}
}
void chain(){
	FOR(i,1,top) v[stk[i]]=0;
	FOR(i,1,top)
		if (d[stk[i]]==1 || top==1) D=stk[i];
	top=0;
	find(D);
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][0]]=1;
	f[1][1][G[stk[1]][1]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	F[0]=F[1]=0;
	FOR(l,0,1)
		FOR(p,0,1)
			(F[p]+=f[top][l][p])%=MO;
	LL x=g[0],y=g[1];
	g[0]=(x*F[0]+y*F[1])%MO;
	g[1]=(x*F[1]+y*F[0])%MO;
}
void circle(){
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][0]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
	for (int i=0;i<a[stk[top]].size();++i)
		if (a[stk[top]][i].fi==stk[1]){
			tmp[a[stk[top]][i].se]^=1;
		}
	F[0]=F[1]=0;
	FOR(l,0,1)
		FOR(p,0,1){
			int s=0;
			for (int L=0;L<M[l][0].size();++L)
				s^=tmp[M[l][0][L]];
			(F[p^s]+=f[top][l][p])%=MO;
		}
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][1][G[stk[1]][1]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
	for (int i=0;i<a[stk[top]].size();++i)
		if (a[stk[top]][i].fi==stk[1]){
			tmp[a[stk[top]][i].se]^=1;
		}
	FOR(l,0,1)
		FOR(p,0,1){
			int s=0;
			for (int L=0;L<M[l][1].size();++L)
				s^=tmp[M[l][1][L]];
			(F[p^s]+=f[top][l][p])%=MO;
		}

	LL x=g[0],y=g[1];
	g[0]=(x*F[0]+y*F[1])%MO;
	g[1]=(x*F[1]+y*F[0])%MO;
}
int main(){
	scanf("%d%d",&n,&m);
	FOR(i,1,n){
		getint(k);
		if (k==2){
			getint(x),getint(y);
			if (abs(x)==abs(y)){
				if (x==y && x>0) G[x][1]^=1;
				else if (x==y && x<0) G[-x][0]^=1;
				else tag^=1;
				continue;
			}
			flag=0;
			for (int p=0;p<a[abs(x)].size();++p)
				if (a[abs(x)][p].fi==abs(y)) flag=1;
			if (!flag) d[abs(x)]++,d[abs(y)]++;
			if (x<0 && y<0) tp=1;
			else if (x<0 && y>0) tp=2;
			else if (x>0 && y<0) tp=3;
			else tp=0;
			a[abs(x)].pb(mp(abs(y),tp));
			swap(x,y);
			if (x<0 && y<0) tp=1;
			else if (x<0 && y>0) tp=2;
			else if (x>0 && y<0) tp=3;
			else tp=0;
			a[abs(x)].pb(mp(abs(y),tp));
		}
		else{
			getint(x);
			if (x>0) G[x][1]^=1;
			else G[x][0]^=1;
		}
	}
	M[0][0].pb(1),M[0][0].pb(2),M[0][0].pb(3);
	M[0][1].pb(2),M[0][1].pb(1),M[0][1].pb(0);
	M[1][0].pb(0),M[1][0].pb(3),M[1][0].pb(1);
	M[1][1].pb(0),M[1][1].pb(2),M[1][1].pb(3);
	g[0]=1;
	FOR(i,1,m)
		if (!v[i]){
			top=0;
			++bl;
			find(i);
			flag=0;
			FOR(j,1,top)
				if (d[stk[j]]==1) flag=1;
			if (flag || top<3) chain();
			else circle();
		}
	cout<<g[1^tag]<<endl;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
vector<pa> a[200010];
vector<int> M[2][2];
int n,m,k,x,y,top,D,tmp[4],tag,bl,F[200010],g[200010],stk[200010],G[200010][2],tp,d[200010],f[200010][2][2];
bool v[200010],flag;
void find(int x){
	v[x]=1;
	stk[++top]=x;
	for (int i=0;i<a[x].size();++i){
		int y=a[x][i].fi;
		if (!v[y]) find(y);
	}
}
void chain(){
	FOR(i,1,top) v[stk[i]]=0;
	FOR(i,1,top)
		if (d[stk[i]]==1 || top==1) D=stk[i];
	top=0;
	find(D);
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][0]]=1;
	f[1][1][G[stk[1]][1]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	F[0]=F[1]=0;
	FOR(l,0,1)
		FOR(p,0,1)
			(F[p]+=f[top][l][p])%=MO;
	LL x=g[0],y=g[1];
	g[0]=(x*F[0]+y*F[1])%MO;
	g[1]=(x*F[1]+y*F[0])%MO;
}
void circle(){
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][0]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
	for (int i=0;i<a[stk[top]].size();++i)
		if (a[stk[top]][i].fi==stk[1]){
			tmp[a[stk[top]][i].se]^=1;
		}
	F[0]=F[1]=0;
	FOR(l,0,1)
		FOR(p,0,1){
			int s=0;
			for (int L=0;L<M[l][0].size();++L)
				s^=tmp[M[l][0][L]];
			(F[p^s]+=f[top][l][p])%=MO;
		}
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][1][G[stk[1]][1]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
	for (int i=0;i<a[stk[top]].size();++i)
		if (a[stk[top]][i].fi==stk[1]){
			tmp[a[stk[top]][i].se]^=1;
		}
	FOR(l,0,1)
		FOR(p,0,1){
			int s=0;
			for (int L=0;L<M[l][1].size();++L)
				s^=tmp[M[l][1][L]];
			(F[p^s]+=f[top][l][p])%=MO;
		}

	LL x=g[0],y=g[1];
	g[0]=(x*F[0]+y*F[1])%MO;
	g[1]=(x*F[1]+y*F[0])%MO;
}
int main(){
	scanf("%d%d",&n,&m);
	FOR(i,1,n){
		getint(k);
		if (k==2){
			getint(x),getint(y);
			if (abs(x)==abs(y)){
				if (x==y && x>0) G[x][1]^=1;
				else if (x==y && x<0) G[-x][0]^=1;
				else tag^=1;
				continue;
			}
			flag=0;
			if (lower_bound(a[abs(x)].begin(),a[abs(x)].end(),mp(abs(y),0))!=a[abs(x)].end()){
				if ((*lower_bound(a[abs(x)].begin(),a[abs(x)].end(),mp(abs(y),0))).fi==abs(y)) flag=1;
			}
			if (!flag) d[abs(x)]++,d[abs(y)]++;
			if (x<0 && y<0) tp=1;
			else if (x<0 && y>0) tp=2;
			else if (x>0 && y<0) tp=3;
			else tp=0;
			a[abs(x)].pb(mp(abs(y),tp));
			swap(x,y);
			if (x<0 && y<0) tp=1;
			else if (x<0 && y>0) tp=2;
			else if (x>0 && y<0) tp=3;
			else tp=0;
			a[abs(x)].pb(mp(abs(y),tp));
		}
		else{
			getint(x);
			if (x>0) G[x][1]^=1;
			else G[x][0]^=1;
		}
	}
	M[0][0].pb(1),M[0][0].pb(2),M[0][0].pb(3);
	M[0][1].pb(2),M[0][1].pb(1),M[0][1].pb(0);
	M[1][0].pb(0),M[1][0].pb(3),M[1][0].pb(1);
	M[1][1].pb(0),M[1][1].pb(2),M[1][1].pb(3);
	g[0]=1;
	FOR(i,1,m)
		if (!v[i]){
			top=0;
			++bl;
			find(i);
			flag=0;
			FOR(j,1,top)
				if (d[stk[j]]==1) flag=1;
			if (flag || top<3) chain();
			else circle();
		}
	cout<<g[1^tag]<<endl;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
vector<pa> a[200010];
vector<int> M[2][2];
int n,m,k,x,y,top,D,tmp[4],tag,bl,F[200010],g[200010],stk[200010],G[200010][2],tp,d[200010],f[200010][2][2];
bool v[200010],flag;
void find(int x){
	v[x]=1;
	stk[++top]=x;
	for (int i=0;i<a[x].size();++i){
		int y=a[x][i].fi;
		if (!v[y]) find(y);
	}
}
void chain(){
	FOR(i,1,top) v[stk[i]]=0;
	FOR(i,1,top)
		if (d[stk[i]]==1 || top==1) D=stk[i];
	top=0;
	find(D);
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][0]]=1;
	f[1][1][G[stk[1]][1]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	F[0]=F[1]=0;
	FOR(l,0,1)
		FOR(p,0,1)
			(F[p]+=f[top][l][p])%=MO;
	LL x=g[0],y=g[1];
	g[0]=(x*F[0]+y*F[1])%MO;
	g[1]=(x*F[1]+y*F[0])%MO;
}
void circle(){
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][0]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
	for (int i=0;i<a[stk[top]].size();++i)
		if (a[stk[top]][i].fi==stk[1]){
			tmp[a[stk[top]][i].se]^=1;
		}
	F[0]=F[1]=0;
	FOR(l,0,1)
		FOR(p,0,1){
			int s=0;
			for (int L=0;L<M[l][0].size();++L)
				s^=tmp[M[l][0][L]];
			(F[p^s]+=f[top][l][p])%=MO;
		}
	FOR(i,0,top)
		FOR(j,0,1)
			FOR(k,0,1)
				f[i][j][k]=0;
	f[1][0][G[stk[1]][1]]=1;
	FOR(i,1,top-1)
		FOR(j,0,1)
			FOR(k,0,1)
				if (f[i][j][k]){
					int x=stk[i],y=stk[i+1];
					tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
					for (int l=0;l<a[x].size();++l)
						if (a[x][l].fi==y) tmp[a[x][l].se]^=1;
					FOR(l,0,1){
						int s=0;
						for (int L=0;L<M[j][l].size();++L)
							s^=tmp[M[j][l][L]];
						(f[i+1][l][k^s^G[y][l]]+=f[i][j][k])%=MO;
					}
				}
	tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
	for (int i=0;i<a[stk[top]].size();++i)
		if (a[stk[top]][i].fi==stk[1]){
			tmp[a[stk[top]][i].se]^=1;
		}
	FOR(l,0,1)
		FOR(p,0,1){
			int s=0;
			for (int L=0;L<M[l][1].size();++L)
				s^=tmp[M[l][1][L]];
			(F[p^s]+=f[top][l][p])%=MO;
		}

	LL x=g[0],y=g[1];
	g[0]=(x*F[0]+y*F[1])%MO;
	g[1]=(x*F[1]+y*F[0])%MO;
}
int main(){
	scanf("%d%d",&n,&m);
	FOR(i,1,n){
		getint(k);
		if (k==2){
			getint(x),getint(y);
			if (abs(x)==abs(y)){
				if (x==y && x>0) G[x][1]^=1;
				else if (x==y && x<0) G[-x][0]^=1;
				else tag^=1;
				continue;
			}
			flag=0;
			if (lower_bound(a[abs(x)].begin(),a[abs(x)].end(),mp(abs(y),0))!=a[abs(x)].end()){
				if ((*lower_bound(a[abs(x)].begin(),a[abs(x)].end(),mp(abs(y),0))).fi==abs(y)) flag=1;
			}
			if (!flag) d[abs(x)]++,d[abs(y)]++;
			if (x<0 && y<0) tp=1;
			else if (x<0 && y>0) tp=2;
			else if (x>0 && y<0) tp=3;
			else tp=0;
			a[abs(x)].pb(mp(abs(y),tp));
			swap(x,y);
			if (x<0 && y<0) tp=1;
			else if (x<0 && y>0) tp=2;
			else if (x>0 && y<0) tp=3;
			else tp=0;
			a[abs(x)].pb(mp(abs(y),tp));
		}
		else{
			getint(x);
			if (x>0) G[x][1]^=1;
			else G[x][0]^=1;
		}
	}
	M[0][0].pb(1),M[0][0].pb(2),M[0][0].pb(3);
	M[0][1].pb(2),M[0][1].pb(1),M[0][1].pb(0);
	M[1][0].pb(0),M[1][0].pb(3),M[1][0].pb(1);
	M[1][1].pb(0),M[1][1].pb(2),M[1][1].pb(3);
	g[0]=1;
	FOR(i,1,m)
		if (!v[i]){
			top=0;
			++bl;
			find(i);
			flag=0;
			FOR(j,1,top)
				if (d[stk[j]]==1) flag=1;
			if (flag || top<3) chain();
			else circle();
		}
	cout<<g[1^tag]<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return a > val ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

const int maxn = 100000 + 10;
int n, m;
int k[maxn];
int a[maxn][2];
int b[maxn];
vi g[maxn];
vii adj[maxn];
int vis[maxn];
int f[maxn][2][2];
int dp[maxn][2];
vector<pair<int, pi> > his;

void clear() {
	while (sz(his)) {
		int u = his.back().fi;
		int aa = his.back().se.fi;
		int b = his.back().se.se;
		f[u][aa][b] = -1;
		his.pop_back();
	}
}

int calc(int u, int x, int y, int pv, int bg, int val) {
	if (u == bg) return x == 0 && y == val;
	vis[u] = 1;
	his.pb(mp(u, mp(x, y)));
	int& res = f[u][x][y];
	if (~res) return res;
	res = 0;
	if (k[u] == 1) {
		if (a[u][0] > 0) return res = x == y;
		else return res = x == (y ^ 1);
	}
	else {
		if (abs(a[u][0]) != (pv >> 1)) swap(a[u][0], a[u][1]);
		int t = y; if (a[u][0] < 0) t = y ^ 1;
		if (sz(adj[u]) == 1) {
			if (!x && t) return res;
			if (t) return res = 2;
			return res = 1;
		}
		if (adj[u][0].se == (pv ^ 1)) {
			swap(adj[u][0], adj[u][1]);
		}
		int v = adj[u][0].fi;
		int w = adj[u][0].se;
		if (a[u][1] > 0) {
			addmod(res, calc(v, x ^ (0 | t), 0, w, bg, val));
			addmod(res, calc(v, x ^ (1 | t), 1, w, bg, val));
		}
		else {
			addmod(res, calc(v, x ^ (1 | t), 0, w, bg, val));
			addmod(res, calc(v, x ^ (0 | t), 1, w, bg, val));
		}
	}
	return res;
}

void solve() {
	cin >> n >> m;
	FOR(i, 0, n) {
		cin >> k[i];
		FOR(j, 0, k[i]) {
			cin >> a[i][j];
			g[abs(a[i][j])].pb(i);
			b[abs(a[i][j])] = 1;
		}
	}
	FOR(i, 1, m + 1) {
		if (sz(g[i]) == 2) {
			int u = g[i][0];
			int v = g[i][1];
			adj[u].pb(mp(v, i << 1));
			adj[v].pb(mp(u, i << 1 | 1));
		}
	}
	ms(f, -1);
	vii vv;
	FOR(i, 0, n) if (!vis[i] && sz(adj[i]) == 1) {
		int r0 = 0, r1 = 0;
		if (k[i] == 1) {
			int v = adj[i][0].fi;
			int w = adj[i][0].se;
			FOR(x, 0, 2) {
				int xx = x;
				if (a[i][0] < 0) xx ^= 1;
				clear();
				addmod(r0, calc(v, xx ^ 0, x, w, i, x));
				addmod(r1, calc(v, xx ^ 1, x, w, i, x));
			}
		}
		else {
			int v = adj[i][0].fi;
			int w = adj[i][0].se;
			if (abs(a[i][0]) == (w >> 1)) {
				swap(a[i][0], a[i][1]);
			}
			FOR(x, 0, 2) FOR(y, 0, 2) {
				int xx = x, yy = y;
				if (a[i][0] < 0) xx ^= 1;
				if (a[i][1] < 0) yy ^= 1;
				clear();
				addmod(r0, calc(v, (xx | yy) ^ 0, y, w, i, x));
				addmod(r1, calc(v, (xx | yy) ^ 1, y, w, i, x));
			}
		}
		vv.pb(mp(r0, r1));
	}
	FOR(i, 0, n) if (!vis[i] && sz(adj[i]) == 2) {
		int r0 = 0, r1 = 0;
		int v = adj[i][0].fi;
		int w = adj[i][0].se;
		if (abs(a[i][0]) == (w >> 1)) {
			swap(a[i][0], a[i][1]);
		}
		FOR(x, 0, 2) FOR(y, 0, 2) {
			int xx = x, yy = y;
			if (a[i][0] < 0) xx ^= 1;
			if (a[i][1] < 0) yy ^= 1;
			clear();
			addmod(r0, calc(v, (xx | yy) ^ 0, y, w, i, x));
			addmod(r1, calc(v, (xx | yy) ^ 1, y, w, i, x));
		}
		vv.pb(mp(r0, r1));
	}
	FOR(i, 0, n) if (!vis[i] && !sz(adj[i])) {
		if (k[i] == 1) {
			vv.pb(mp(1, 1));
		}
		else {
			vv.pb(mp(1, 3));
		}
	}
	dp[0][0] = 1;
	FOR(i, 1, sz(vv) + 1) {
		dp[i][0] = mult(dp[i - 1][0], vv[i - 1].fi);
		addmod(dp[i][0], mult(dp[i - 1][1], vv[i - 1].se));
		dp[i][1] = mult(dp[i - 1][1], vv[i - 1].fi);
		addmod(dp[i][1], mult(dp[i - 1][0], vv[i - 1].se));
	}
	int ans = dp[sz(vv)][1];
	FOR(i, 1, m + 1) {
		if (!b[i]) {
			ans = mult(ans, 2);
		}
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return a > val ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

const int maxn = 100000 + 10;
int n, m;
int k[maxn];
int a[maxn][2];
int b[maxn];
vi g[maxn];
vii adj[maxn];
int vis[maxn];
int f[maxn][2][2];
int dp[maxn][2];
vector<pair<int, pi> > his;

void clear() {
	while (sz(his)) {
		int u = his.back().fi;
		int aa = his.back().se.fi;
		int b = his.back().se.se;
		f[u][aa][b] = -1;
		his.pop_back();
	}
}

int calc(int u, int x, int y, int pv, int bg, int val) {
	if (u == bg) return x == 0 && y == val;
	vis[u] = 1;
	his.pb(mp(u, mp(x, y)));
	int& res = f[u][x][y];
	if (~res) return res;
	res = 0;
	if (k[u] == 1) {
		if (a[u][0] > 0) return res = x == y;
		else return res = x == (y ^ 1);
	}
	else {
		if (abs(a[u][0]) != (pv >> 1)) swap(a[u][0], a[u][1]);
		int t = y; if (a[u][0] < 0) t = y ^ 1;
		if (sz(adj[u]) == 1) {
			if (!x && t) return res;
			if (t) return res = 2;
			return res = 1;
		}
		if (adj[u][0].se == (pv ^ 1)) {
			swap(adj[u][0], adj[u][1]);
		}
		int v = adj[u][0].fi;
		int w = adj[u][0].se;
		if (a[u][1] > 0) {
			addmod(res, calc(v, x ^ (0 | t), 0, w, bg, val));
			addmod(res, calc(v, x ^ (1 | t), 1, w, bg, val));
		}
		else {
			addmod(res, calc(v, x ^ (1 | t), 0, w, bg, val));
			addmod(res, calc(v, x ^ (0 | t), 1, w, bg, val));
		}
	}
	return res;
}

void solve() {
	cin >> n >> m;
	FOR(i, 0, n) {
		cin >> k[i];
		FOR(j, 0, k[i]) {
			cin >> a[i][j];
			g[abs(a[i][j])].pb(i);
			b[abs(a[i][j])] = 1;
		}
	}
	FOR(i, 1, m + 1) {
		if (sz(g[i]) == 2) {
			int u = g[i][0];
			int v = g[i][1];
			adj[u].pb(mp(v, i << 1));
			adj[v].pb(mp(u, i << 1 | 1));
		}
	}
	ms(f, -1);
	vii vv;
	FOR(i, 0, n) if (!vis[i] && sz(adj[i]) == 1) {
		int r0 = 0, r1 = 0;
		if (k[i] == 1) {
			int v = adj[i][0].fi;
			int w = adj[i][0].se;
			FOR(x, 0, 2) {
				int xx = x;
				if (a[i][0] < 0) xx ^= 1;
				clear();
				addmod(r0, calc(v, xx ^ 0, x, w, i, x));
				addmod(r1, calc(v, xx ^ 1, x, w, i, x));
			}
		}
		else {
			int v = adj[i][0].fi;
			int w = adj[i][0].se;
			if (abs(a[i][0]) == (w >> 1)) {
				swap(a[i][0], a[i][1]);
			}
			FOR(x, 0, 2) FOR(y, 0, 2) {
				int xx = x, yy = y;
				if (a[i][0] < 0) xx ^= 1;
				if (a[i][1] < 0) yy ^= 1;
				clear();
				addmod(r0, calc(v, (xx | yy) ^ 0, y, w, i, x));
				addmod(r1, calc(v, (xx | yy) ^ 1, y, w, i, x));
			}
		}
		vv.pb(mp(r0, r1));
	}
	FOR(i, 0, n) if (!vis[i] && sz(adj[i]) == 2) {
		int r0 = 0, r1 = 0;
		int v = adj[i][0].fi;
		int w = adj[i][0].se;
		if (abs(a[i][0]) == (w >> 1)) {
			swap(a[i][0], a[i][1]);
		}
		FOR(x, 0, 2) FOR(y, 0, 2) {
			int xx = x, yy = y;
			if (a[i][0] < 0) xx ^= 1;
			if (a[i][1] < 0) yy ^= 1;
			clear();
			addmod(r0, calc(v, (xx | yy) ^ 0, y, w, i, x));
			addmod(r1, calc(v, (xx | yy) ^ 1, y, w, i, x));
		}
		vv.pb(mp(r0, r1));
	}
	FOR(i, 0, n) if (!vis[i] && !sz(adj[i])) {
		if (!k[i]) {
			vv.pb(mp(1, 1));
		}
		else {
			vv.pb(mp(1, 3));
		}
	}
	dp[0][0] = 1;
	FOR(i, 1, sz(vv) + 1) {
		dp[i][0] = mult(dp[i - 1][0], vv[i - 1].fi);
		addmod(dp[i][0], mult(dp[i - 1][1], vv[i - 1].se));
		dp[i][1] = mult(dp[i - 1][1], vv[i - 1].fi);
		addmod(dp[i][1], mult(dp[i - 1][0], vv[i - 1].se));
	}
	int ans = dp[sz(vv)][1];
	FOR(i, 1, m + 1) {
		if (!b[i]) {
			ans = mult(ans, 2);
		}
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return a > val ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

const int maxn = 100000 + 10;
int n, m;
int k[maxn];
int a[maxn][2];
int b[maxn];
vi g[maxn];
vii adj[maxn];
int vis[maxn];
int f[maxn][2][2];
int dp[maxn][2];
vector<pair<int, pi> > his;

void clear() {
	while (sz(his)) {
		int u = his.back().fi;
		int aa = his.back().se.fi;
		int b = his.back().se.se;
		f[u][aa][b] = -1;
		his.pop_back();
	}
}

int calc(int u, int x, int y, int pv, int bg, int val) {
	if (u == bg) return x == 0 && y == val;
	vis[u] = 1;
	his.pb(mp(u, mp(x, y)));
	int& res = f[u][x][y];
	if (~res) return res;
	res = 0;
	if (k[u] == 1) {
		if (a[u][0] > 0) return res = x == y;
		else return res = x == (y ^ 1);
	}
	else {
		if (abs(a[u][0]) != (pv >> 1)) swap(a[u][0], a[u][1]);
		int t = y; if (a[u][0] < 0) t = y ^ 1;
		if (sz(adj[u]) == 1) {
			if (!x && t) return res;
			if (t) return res = 2;
			return res = 1;
		}
		if (adj[u][0].se == (pv ^ 1)) {
			swap(adj[u][0], adj[u][1]);
		}
		int v = adj[u][0].fi;
		int w = adj[u][0].se;
		if (a[u][1] > 0) {
			addmod(res, calc(v, x ^ (0 | t), 0, w, bg, val));
			addmod(res, calc(v, x ^ (1 | t), 1, w, bg, val));
		}
		else {
			addmod(res, calc(v, x ^ (1 | t), 0, w, bg, val));
			addmod(res, calc(v, x ^ (0 | t), 1, w, bg, val));
		}
	}
	return res;
}

void solve() {
	cin >> n >> m;
	FOR(i, 0, n) {
		cin >> k[i];
		FOR(j, 0, k[i]) {
			cin >> a[i][j];
			g[abs(a[i][j])].pb(i);
			b[abs(a[i][j])] = 1;
		}
	}
	FOR(i, 1, m + 1) {
		if (sz(g[i]) == 2) {
			int u = g[i][0];
			int v = g[i][1];
			adj[u].pb(mp(v, i << 1));
			adj[v].pb(mp(u, i << 1 | 1));
		}
	}
	ms(f, -1);
	vii vv;
	FOR(i, 0, n) if (!vis[i] && sz(adj[i]) == 1) {
		int r0 = 0, r1 = 0;
		if (k[i] == 1) {
			int v = adj[i][0].fi;
			int w = adj[i][0].se;
			FOR(x, 0, 2) {
				int xx = x;
				if (a[i][0] < 0) xx ^= 1;
				clear();
				addmod(r0, calc(v, xx ^ 0, x, w, i, x));
				addmod(r1, calc(v, xx ^ 1, x, w, i, x));
			}
		}
		else {
			int v = adj[i][0].fi;
			int w = adj[i][0].se;
			if (abs(a[i][0]) == (w >> 1)) {
				swap(a[i][0], a[i][1]);
			}
			FOR(x, 0, 2) FOR(y, 0, 2) {
				int xx = x, yy = y;
				if (a[i][0] < 0) xx ^= 1;
				if (a[i][1] < 0) yy ^= 1;
				clear();
				addmod(r0, calc(v, (xx | yy) ^ 0, y, w, i, x));
				addmod(r1, calc(v, (xx | yy) ^ 1, y, w, i, x));
			}
		}
		vv.pb(mp(r0, r1));
	}
	FOR(i, 0, n) if (!vis[i] && sz(adj[i]) == 2) {
		int r0 = 0, r1 = 0;
		int v = adj[i][0].fi;
		int w = adj[i][0].se;
		if (abs(a[i][0]) == (w >> 1)) {
			swap(a[i][0], a[i][1]);
		}
		FOR(x, 0, 2) FOR(y, 0, 2) {
			int xx = x, yy = y;
			if (a[i][0] < 0) xx ^= 1;
			if (a[i][1] < 0) yy ^= 1;
			clear();
			addmod(r0, calc(v, (xx | yy) ^ 0, y, w, i, x));
			addmod(r1, calc(v, (xx | yy) ^ 1, y, w, i, x));
		}
		vv.pb(mp(r0, r1));
	}
	FOR(i, 0, n) if (!vis[i] && !sz(adj[i])) {
		vv.pb(mp(k[i], k[i]));
	}
	dp[0][0] = 1;
	FOR(i, 1, sz(vv) + 1) {
		dp[i][0] = mult(dp[i - 1][0], vv[i - 1].fi);
		addmod(dp[i][0], mult(dp[i - 1][1], vv[i - 1].se));
		dp[i][1] = mult(dp[i - 1][1], vv[i - 1].fi);
		addmod(dp[i][1], mult(dp[i - 1][0], vv[i - 1].se));
	}
	int ans = dp[sz(vv)][1];
	FOR(i, 1, m + 1) {
		if (!b[i]) {
			ans = mult(ans, 2);
		}
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=1e5+5,mod=1e9+7;
int n,m,sz,cir;
int a[maxn][2],cnt[maxn],vis[maxn],toti[maxn],totj[maxn],used[maxn];
int ans0,ans1,f[maxn][2][2][2];
int q[maxn][2];
void dfs(int i,int j){
	vis[i]=1;
	sz++;
	rep2(k,0,cnt[i]){
		if(a[i][k]>0){
			if(j)q[sz][cnt[i]-1-k]=0;
			else q[sz][k]=0;
		}else{
			if(j)q[sz][cnt[i]-1-k]=1;
			else q[sz][k]=1;
		}
	}
	int tail=abs(a[i][cnt[i]-1-j]);
	int nxti=toti[tail]-i,nxtj=totj[tail]-(cnt[i]-1-j);
	if(!nxti)return;
	if(!vis[nxti])dfs(nxti,nxtj);
	else if(cnt[i]==2)cir=1;
}
int add(int x,int y){
	return x+y>=mod?x+y-mod:x+y;
}
void upd(int &x,int y){
	x=add(x,y);
}
void DP(){
	rep(i,0,sz)memset(f[i],0,sizeof f[i]);
//	cerr<<"----"<<endl;
//	rep(i,1,sz)cerr<<q[i][0]<<" "<<q[i][1]<<endl;
	f[0][0][0][0]=f[0][1][0][1]=1;
	rep(i,0,sz-1)rep(j,0,1)rep(k,0,1)rep(l,0,1){
		int nxti=i+1,nxtl=l;
		if((!i)&&(q[nxti][1]==-1)){
			int x1=j^q[nxti][0];
			int nxtj=j,nxtk=k^x1;
			upd(f[nxti][nxtj][nxtk][nxtl],f[i][j][k][l]);
		}else if((i==sz-1)&&(q[nxti][1]==-1)){
			int x1=j^q[nxti][0];
			int nxtj=j,nxtk=k^x1;
			upd(f[nxti][nxtj][nxtk][nxtl],f[i][j][k][l]);
		}else{
			rep(nxtj,0,1){
				int x1=j^q[nxti][0],x2=nxtj^q[nxti][1];
				if(q[nxti][0]==-1)assert(0);
				if(q[nxti][1]==-1)assert(0);
				int nxtk=k^(x1|x2);
				upd(f[nxti][nxtj][nxtk][nxtl],f[i][j][k][l]);
			}
		}
	}
//	cerr<<cir<<endl;
	if(!cir){
		int now0=0,now1=0;
		rep(j,0,1)rep(l,0,1)upd(now0,f[sz][j][0][l]),upd(now1,f[sz][j][1][l]);
		int nans0=(1ll*ans0*now0+1ll*ans1*now1)%mod,nans1=(1ll*ans0*now1+1ll*ans1*now0)%mod;
		ans0=nans0;
		ans1=nans1;
	}else{
		int now0=0,now1=0;
		rep(l,0,1)upd(now0,f[sz][l][0][l]),upd(now1,f[sz][l][1][l]);
		int nans0=(1ll*ans0*now0+1ll*ans1*now1)%mod,nans1=(1ll*ans0*now1+1ll*ans1*now0)%mod;
		ans0=nans0;
		ans1=nans1;
	}
}
int main(){
	read(n);read(m);
	ans0=1;
	rep(i,1,n){
		read(cnt[i]);
		rep2(j,0,cnt[i]){
			read(a[i][j]);
			int x=a[i][j];
			if(x>0)toti[x]+=i,totj[x]+=j;
			else toti[-x]+=i,totj[-x]+=j;
			used[abs(a[i][j])]++;
		}
	}
	memset(q,-1,sizeof q);
	rep(i,1,n)if(!vis[i]){
		if((cnt[i]==2)&&(abs(a[i][0])==abs(a[i][1]))){
			if(a[i][0]==a[i][1]){
				int nans0=add(ans0,ans1),nans1=add(ans0,ans1);
				ans0=nans0;ans1=nans1;
			}else{
				int nans0=add(ans1,ans1),nans1=add(ans0,ans0);
				ans0=nans0;ans1=nans1;
			}
			vis[i]=1;
			continue;
		}
	}
	rep(i,1,n)if(!vis[i]){
		rep(j,1,sz)q[j][0]=q[j][1]=-1;
		sz=0;
		cir=0;
		if(cnt[i]==1){
			dfs(i,0);
			DP();
		}else{
			if(used[abs(a[i][0])]==1){
				dfs(i,0);
				DP();
			}else if(used[abs(a[i][1])]==1){
				dfs(i,1);
				DP();
			}
		}
	}
	rep(i,1,n)if(!vis[i]){
		rep(j,1,sz)q[j][0]=q[j][1]=-1;
		sz=0;
		cir=0;
		dfs(i,0);
		DP();
	}
	rep(i,1,m)if(!used[i])ans1=add(ans1,ans1);
	printf("%d\n",ans1);
	return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

const int N=100005;
const int MOD=1000000007;

struct DP
{
	int p;
	int dp[2][2][2];
	DP(int a=0,int b=0,int c=0,int d=0)
	{
		p=0;
		dp[0][0][0]=a,dp[0][0][1]=b,dp[0][1][0]=c,dp[0][1][1]=d;
	}

	inline void trans()
	{
		p=1-p;
		dp[p][0][0]=dp[1-p][1][1]+dp[1-p][0][0];//0F 1T 0F
		dp[p][0][1]=dp[1-p][1][1]+dp[1-p][1][0];//0T 1T 1F
		dp[p][1][0]=dp[1-p][0][1]+dp[1-p][1][0];//1F 0T 1F
		dp[p][1][1]=dp[1-p][0][1]+dp[1-p][0][0];//1T 0T 0F
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				if(dp[p][i][j]>=MOD)
					dp[p][i][j]-=MOD;
	}

	inline void rev()
	{
		for(int i=0;i<2;i++)
			swap(dp[p][i][0],dp[p][i][1]);
	}

	inline void self()
	{
		swap(dp[p][0][1],dp[p][1][1]);
	}

	inline int val(int x,int y)
	{
		return dp[p][x][y];
	}

	inline void print()
	{
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				printf("%d ",dp[p][i][j]);
		printf("\n");
	}
}I;

int n,m;
int cnt;
bool in[N];
int a[N][2];
long long f[N][2];

int to[N];
bool two[N];
int op[N];
bool self[N];
bool diff[N];

inline void Add(int x)
{
//	printf("Add %d\n",x);
	int tmp=(x>0?1:-1);
	x=x*tmp;
	in[x]=true;
//	printf("%d %d\n",tmp,op[x]);
	if(op[x]==0)
		op[x]=tmp;
	else
		if(op[x]!=tmp)
			diff[x]=true;
}

int root,status;
bool vis[N];
vector<int> v[N],rv[N];

inline int Find(int x,int fa)
{
	if(vis[x])
		return -1;
	vis[x]=true;
//	printf("Visit %d\n",x);
	for(int i=0;i<rv[x].size();i++)
		if(rv[x][i]!=fa)
			return Find(rv[x][i],x);
	return x;
}

inline void CalcCycle(int x,int fa)
{
	if(diff[x])
		I.rev();

//	printf("Current %d Root %d\n",x,root);
	for(int i=0;i<v[x].size();i++)
		if(v[x][i]!=fa)
		{
			I.trans();
/*			for(int j=0;j<2;j++)
				for(int k=0;k<2;k++)
					printf("%d ",I.val(j,k));
			printf("\n");*/

			if(v[x][i]==root)
			{
				a[cnt][0]+=I.val(0,status);
				a[cnt][1]+=I.val(1,status);
				return;
			}

			CalcCycle(v[x][i],x);
			return;
		}
}

inline void CalcLine(int x,int fa)
{
	vis[x]=true;
//	printf("%d on line\n",x);
	if(diff[x])
		I.rev();//,printf("Reverse %d\n",x);
//	I.print();
	for(int i=0;i<v[x].size();i++)
		if(v[x][i]!=fa)
		{
			I.trans();
//			I.print();
			CalcLine(v[x][i],x);
			return;
		}

	if(self[x])
		I.self();//,printf("Self %d\n",x);
	a[cnt][0]=I.val(0,0)+I.val(0,1);
	a[cnt][1]=I.val(1,0)+I.val(1,1);
}

inline void Solve(int x)
{
	if(v[x].size()==0)
	{
		a[cnt][0]=1;
		a[cnt][1]=1;
		return;
	}

	root=Find(x,0);
	if(two[root])
	{
		if(diff[root] || diff[v[root][0]])
			a[cnt][0]=a[cnt][1]=2;
		else
			a[cnt][0]=4,a[cnt][1]=0;
		return;
	}
//	printf("Root %d\n",root);
	if(root==-1)
	{
		root=x;
		status=0;
		I=DP(1,0,0,0);
		CalcCycle(root,0);
		status=1;
		I=DP(0,1,0,0);
		CalcCycle(root,0);
	}
	else
	{
		I=DP(1,1,0,0);
		if(self[root])
			I.self();//,printf("Self %d\n",root);
//		I.print();
		CalcLine(root,0);
	}
}

inline void dfs(int x)
{
	printf("%d ",x);
	vis[x]=true;
	for(int i=0;i<v[x].size();i++)
		if(!vis[v[x][i]])
			dfs(v[x][i]);
}

int main()
{
//	freopen("input.txt","r",stdin);
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++)
	{
		int k;
		scanf("%d",&k);
		if(k&1)
		{
			int x;
			scanf("%d",&x);
			Add(x);
			self[abs(x)]=true;
		}
		else
		{
			int x,y;
			scanf("%d%d",&x,&y);
			Add(x),Add(y);
			x=abs(x),y=abs(y);
			v[x].push_back(y);
			rv[y].push_back(x);

			if(to[x]==y)
				two[x]=two[y]=true;
			to[x]=y,to[y]=x;
//			printf("Add Edge %d %d\n",x,y);

			if(x!=y)
			{
				v[y].push_back(x);
				rv[x].push_back(y);
			}
		}
	}

/*	for(int i=1;i<=n;i++)
		printf("%d ",(int)diff[i]);
	printf("\n");
	return 0;*/
/*	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i),printf("\n");
	return 0;*/

	for(int i=1;i<=n;i++)
		if(!vis[i] && in[i])
		{
			cnt++;
			Solve(i);
//			printf("\n");
//			return 0;
		}

/*	for(int i=1;i<=cnt;i++)
		printf("%d %d\n",a[i][0],a[i][1]);*/

	f[0][0]=1;
	for(int i=1;i<=cnt;i++)
	{
		f[i][0]=(f[i-1][1]*a[i][1]+f[i-1][0]*a[i][0])%MOD;
		f[i][1]=(f[i-1][0]*a[i][1]+f[i-1][1]*a[i][0])%MOD;
	}

	int ans=(int)f[cnt][1];
	for(int i=1;i<=n;i++)
		if(!in[i])
		{
			ans<<=1;
			if(ans>MOD)
				ans-=MOD;
		}
	printf("%d\n",ans);
	return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

const int N=100005;
const int MOD=1000000007;

struct DP
{
	int p;
	int dp[2][2][2];
	DP(int a=0,int b=0,int c=0,int d=0)
	{
		p=0;
		dp[0][0][0]=a,dp[0][0][1]=b,dp[0][1][0]=c,dp[0][1][1]=d;
	}

	inline void trans()
	{
		p=1-p;
		dp[p][0][0]=dp[1-p][1][1]+dp[1-p][0][0];//0F 1T 0F
		dp[p][0][1]=dp[1-p][1][1]+dp[1-p][1][0];//0T 1T 1F
		dp[p][1][0]=dp[1-p][0][1]+dp[1-p][1][0];//1F 0T 1F
		dp[p][1][1]=dp[1-p][0][1]+dp[1-p][0][0];//1T 0T 0F
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				if(dp[p][i][j]>=MOD)
					dp[p][i][j]-=MOD;
	}

	inline void rev()
	{
		for(int i=0;i<2;i++)
			swap(dp[p][i][0],dp[p][i][1]);
	}

	inline void self()
	{
		swap(dp[p][0][1],dp[p][1][1]);
	}

	inline int val(int x,int y)
	{
		return dp[p][x][y];
	}
}I;

int n,m;
int cnt;
int a[N][2];
long long f[N][2];

int to[N];
bool two[N];
int op[N];
bool self[N];
bool diff[N];

inline void Add(int x)
{
//	printf("Add %d\n",x);
	int tmp=(x>0?1:-1);
	x=x*tmp;
//	printf("%d %d\n",tmp,op[x]);
	if(op[x]==0)
		op[x]=tmp;
	else
		if(op[x]!=tmp)
			diff[x]=true;
}

int root,status;
bool vis[N];
vector<int> v[N],rv[N];

inline int Find(int x,int fa)
{
	if(vis[x])
		return -1;
	vis[x]=true;
//	printf("Visit %d\n",x);
	for(int i=0;i<rv[x].size();i++)
		if(rv[x][i]!=fa)
			return Find(rv[x][i],x);
	return x;
}

inline void CalcCycle(int x,int fa)
{
	if(diff[x])
		I.rev();

//	printf("Current %d Root %d\n",x,root);
	for(int i=0;i<v[x].size();i++)
		if(v[x][i]!=fa)
		{
			I.trans();
/*			for(int j=0;j<2;j++)
				for(int k=0;k<2;k++)
					printf("%d ",I.val(j,k));
			printf("\n");*/

			if(v[x][i]==root)
			{
				a[cnt][0]+=I.val(0,status);
				a[cnt][1]+=I.val(1,status);
				return;
			}

			CalcCycle(v[x][i],x);
			return;
		}
}

inline void CalcLine(int x,int fa)
{
	vis[x]=true;
//	printf("%d on line\n",x);
	if(diff[x])
		I.rev();//,printf("Reverse %d\n",x);

	for(int i=0;i<v[x].size();i++)
		if(v[x][i]!=fa)
		{
			I.trans();
/*			for(int j=0;j<2;j++)
				for(int k=0;k<2;k++)
					printf("%d ",I.val(j,k));
			printf("\n");*/
			CalcLine(v[x][i],x);
			return;
		}

	if(self[x])
		I.self();//,printf("Self %d\n",x);
	a[cnt][0]=I.val(0,0)+I.val(0,1);
	a[cnt][1]=I.val(1,0)+I.val(1,1);
}

inline void Solve(int x)
{
	if(v[x].size()==0)
	{
		a[cnt][0]=1;
		a[cnt][1]=1;
		return;
	}

	root=Find(x,0);
	if(two[root])
	{
		a[cnt][0]=4;
		a[cnt][1]=0;
		return;
	}
//	printf("Root %d\n",root);
	if(root==-1)
	{
		root=x;
		status=0;
		I=DP(1,0,0,0);
		CalcCycle(root,0);
		status=1;
		I=DP(0,1,0,0);
		CalcCycle(root,0);
	}
	else
	{
		I=DP(1,1,0,0);
		if(self[root])
			I.self();
		CalcLine(root,0);
	}
}

inline void dfs(int x)
{
	printf("%d ",x);
	vis[x]=true;
	for(int i=0;i<v[x].size();i++)
		if(!vis[v[x][i]])
			dfs(v[x][i]);
}

int main()
{
//	freopen("input.txt","r",stdin);
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++)
	{
		int k;
		scanf("%d",&k);
		if(k&1)
		{
			int x;
			scanf("%d",&x);
			Add(x);
			self[abs(x)]=true;
		}
		else
		{
			int x,y;
			scanf("%d%d",&x,&y);
			Add(x),Add(y);
			x=abs(x),y=abs(y);
			v[x].push_back(y);
			rv[y].push_back(x);

			if(to[x]==y)
				two[x]=two[y]=true;
			to[x]=y,to[y]=x;
//			printf("Add Edge %d %d\n",x,y);

			if(x!=y)
			{
				v[y].push_back(x);
				rv[x].push_back(y);
			}
		}
	}

/*	for(int i=1;i<=n;i++)
		printf("%d ",(int)diff[i]);
	printf("\n");
	return 0;*/
/*	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i),printf("\n");
	return 0;*/

	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			cnt++;
			Solve(i);
//			printf("\n");
//			return 0;
		}

/*	for(int i=1;i<=cnt;i++)
		printf("%d %d\n",a[i][0],a[i][1]);*/

	f[0][0]=1;
	for(int i=1;i<=cnt;i++)
	{
		f[i][0]=(f[i-1][1]*a[i][1]+f[i-1][0]*a[i][0])%MOD;
		f[i][1]=(f[i-1][0]*a[i][1]+f[i-1][1]*a[i][0])%MOD;
	}

	printf("%d\n",(int)f[cnt][1]);
	return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

const int N=100005;
const int MOD=1000000007;

struct DP
{
	int p;
	int dp[2][2][2];
	DP(int a=0,int b=0,int c=0,int d=0)
	{
		p=0;
		dp[0][0][0]=a,dp[0][0][1]=b,dp[0][1][0]=c,dp[0][1][1]=d;
	}

	inline void trans()
	{
		p=1-p;
		dp[p][0][0]=dp[1-p][1][1]+dp[1-p][0][0];//0F 1T 0F
		dp[p][0][1]=dp[1-p][1][1]+dp[1-p][1][0];//0T 1T 1F
		dp[p][1][0]=dp[1-p][0][1]+dp[1-p][1][0];//1F 0T 1F
		dp[p][1][1]=dp[1-p][0][1]+dp[1-p][0][0];//1T 0T 0F
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				if(dp[p][i][j]>=MOD)
					dp[p][i][j]-=MOD;
	}

	inline void rev()
	{
		for(int i=0;i<2;i++)
			swap(dp[p][i][0],dp[p][i][1]);
	}

	inline void self()
	{
		swap(dp[p][0][1],dp[p][1][1]);
	}

	inline int val(int x,int y)
	{
		return dp[p][x][y];
	}
}I;

int n,m;
int cnt;
int a[N][2];
long long f[N][2];

int to[N];
bool two[N];
int op[N];
bool self[N];
bool diff[N];

inline void Add(int x)
{
//	printf("Add %d\n",x);
	int tmp=(x>0?1:-1);
	x=x*tmp;
//	printf("%d %d\n",tmp,op[x]);
	if(op[x]==0)
		op[x]=tmp;
	else
		if(op[x]!=tmp)
			diff[x]=true;
}

int root,status;
bool vis[N];
vector<int> v[N],rv[N];

inline int Find(int x,int fa)
{
	if(vis[x])
		return -1;
	vis[x]=true;
//	printf("Visit %d\n",x);
	for(int i=0;i<rv[x].size();i++)
		if(rv[x][i]!=fa)
			return Find(rv[x][i],x);
	return x;
}

inline void CalcCycle(int x,int fa)
{
	if(diff[x])
		I.rev();

//	printf("Current %d Root %d\n",x,root);
	for(int i=0;i<v[x].size();i++)
		if(v[x][i]!=fa)
		{
			I.trans();
/*			for(int j=0;j<2;j++)
				for(int k=0;k<2;k++)
					printf("%d ",I.val(j,k));
			printf("\n");*/

			if(v[x][i]==root)
			{
				a[cnt][0]+=I.val(0,status);
				a[cnt][1]+=I.val(1,status);
				return;
			}

			CalcCycle(v[x][i],x);
			return;
		}
}

inline void CalcLine(int x,int fa)
{
	vis[x]=true;
//	printf("%d on line\n",x);
	if(diff[x])
		I.rev();//,printf("Reverse %d\n",x);

	for(int i=0;i<v[x].size();i++)
		if(v[x][i]!=fa)
		{
			I.trans();
/*			for(int j=0;j<2;j++)
				for(int k=0;k<2;k++)
					printf("%d ",I.val(j,k));
			printf("\n");*/
			CalcLine(v[x][i],x);
			return;
		}

	if(self[x])
		I.self();//,printf("Self %d\n",x);
	a[cnt][0]=I.val(0,0)+I.val(0,1);
	a[cnt][1]=I.val(1,0)+I.val(1,1);
}

inline void Solve(int x)
{
	root=Find(x,0);
	if(two[root])
	{
		a[cnt][0]=4;
		a[cnt][1]=0;
		return;
	}
//	printf("Root %d\n",root);
	if(root==-1)
	{
		root=x;
		status=0;
		I=DP(1,0,0,0);
		CalcCycle(root,0);
		status=1;
		I=DP(0,1,0,0);
		CalcCycle(root,0);
	}
	else
	{
		I=DP(1,1,0,0);
		if(self[root])
			I.self();
		CalcLine(root,0);
	}
}

inline void dfs(int x)
{
	printf("%d ",x);
	vis[x]=true;
	for(int i=0;i<v[x].size();i++)
		if(!vis[v[x][i]])
			dfs(v[x][i]);
}

int main()
{
//	freopen("input.txt","r",stdin);
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++)
	{
		int k;
		scanf("%d",&k);
		if(k&1)
		{
			int x;
			scanf("%d",&x);
			Add(x);
			self[abs(x)]=true;
		}
		else
		{
			int x,y;
			scanf("%d%d",&x,&y);
			Add(x),Add(y);
			x=abs(x),y=abs(y);
			v[x].push_back(y);
			rv[y].push_back(x);

			if(to[x]==y)
				two[x]=two[y]=true;
			to[x]=y,to[y]=x;
//			printf("Add Edge %d %d\n",x,y);

			if(x!=y)
			{
				v[y].push_back(x);
				rv[x].push_back(y);
			}
		}
	}

/*	for(int i=1;i<=n;i++)
		printf("%d ",(int)diff[i]);
	printf("\n");
	return 0;*/
/*	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i),printf("\n");
	return 0;*/

	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			cnt++;
			Solve(i);
//			printf("\n");
//			return 0;
		}

/*	for(int i=1;i<=cnt;i++)
		printf("%d %d\n",a[i][0],a[i][1]);*/

	f[0][0]=1;
	for(int i=1;i<=cnt;i++)
	{
		f[i][0]=(f[i-1][1]*a[i][1]+f[i-1][0]*a[i][0])%MOD;
		f[i][1]=(f[i-1][0]*a[i][1]+f[i-1][1]*a[i][0])%MOD;
	}

	printf("%d\n",(int)f[cnt][1]);
	return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

const int N=100005;
const int MOD=1000000007;

struct DP
{
	int p;
	int dp[2][2][2];
	DP(int a=0,int b=0,int c=0,int d=0)
	{
		p=0;
		dp[0][0][0]=a,dp[0][0][1]=b,dp[0][1][0]=c,dp[0][1][1]=d;
	}

	inline void trans()
	{
		p=1-p;
		dp[p][0][0]=dp[1-p][1][1]+dp[1-p][0][0];//0F 1T 0F
		dp[p][0][1]=dp[1-p][1][1]+dp[1-p][1][0];//0T 1T 1F
		dp[p][1][0]=dp[1-p][0][1]+dp[1-p][1][0];//1F 0T 1F
		dp[p][1][1]=dp[1-p][0][1]+dp[1-p][0][0];//1T 0T 0F
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				if(dp[p][i][j]>=MOD)
					dp[p][i][j]-=MOD;
	}

	inline void rev()
	{
		for(int i=0;i<2;i++)
			swap(dp[p][i][0],dp[p][i][1]);
	}

	inline void self()
	{
		swap(dp[p][0][1],dp[p][1][1]);
	}

	inline int val(int x,int y)
	{
		return dp[p][x][y];
	}
}I;

int n,m;
int cnt;
bool in[N];
int a[N][2];
long long f[N][2];

int to[N];
bool two[N];
int op[N];
bool self[N];
bool diff[N];

inline void Add(int x)
{
	int tmp=(x>0?1:-1);
	x=x*tmp;
	in[x]=true;
	if(op[x]==0)
		op[x]=tmp;
	else
		if(op[x]!=tmp)
			diff[x]=true;
}

int root,status;
bool vis[N];
vector<int> v[N],rv[N];

inline int Find(int x,int fa)
{
	if(vis[x])
		return -1;
	vis[x]=true;
	for(int i=0;i<rv[x].size();i++)
		if(rv[x][i]!=fa)
			return Find(rv[x][i],x);
	return x;
}

inline void CalcCycle(int x,int fa)
{
	if(diff[x])
		I.rev();

	for(int i=0;i<v[x].size();i++)
		if(v[x][i]!=fa)
		{
			I.trans();
			if(v[x][i]==root)
			{
				a[cnt][0]+=I.val(0,status);
				a[cnt][1]+=I.val(1,status);
				return;
			}

			CalcCycle(v[x][i],x);
			return;
		}
}

inline void CalcLine(int x,int fa)
{
	vis[x]=true;
	if(diff[x])
		I.rev();

	for(int i=0;i<v[x].size();i++)
		if(v[x][i]!=fa)
		{
			I.trans();
			CalcLine(v[x][i],x);
			return;
		}

	if(self[x])
		I.self();
	a[cnt][0]=I.val(0,0)+I.val(0,1);
	a[cnt][1]=I.val(1,0)+I.val(1,1);
}

inline void Solve(int x)
{
	if(v[x].size()==0)
	{
		a[cnt][0]=1;
		a[cnt][1]=1;
		return;
	}

	root=Find(x,0);
	if(two[root])
	{
		if(diff[root] || diff[v[root][0]])
			a[cnt][0]=a[cnt][1]=2;
		else
			a[cnt][0]=4,a[cnt][1]=0;
		return;
	}

	if(root==-1)
	{
		root=x;
		status=0;
		I=DP(1,0,0,0);
		CalcCycle(root,0);
		status=1;
		I=DP(0,1,0,0);
		CalcCycle(root,0);
	}
	else
	{
		I=DP(1,1,0,0);
		if(self[root])
			I.self();
		CalcLine(root,0);
	}
}

inline void dfs(int x)
{
	printf("%d ",x);
	vis[x]=true;
	for(int i=0;i<v[x].size();i++)
		if(!vis[v[x][i]])
			dfs(v[x][i]);
}

int main()
{
//	freopen("input.txt","r",stdin);
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++)
	{
		int k;
		scanf("%d",&k);
		if(k&1)
		{
			int x;
			scanf("%d",&x);
			Add(x);
			self[abs(x)]=true;
		}
		else
		{
			int x,y;
			scanf("%d%d",&x,&y);
			Add(x),Add(y);
			x=abs(x),y=abs(y);
			v[x].push_back(y);
			rv[y].push_back(x);

			if(to[x]==y)
				two[x]=two[y]=true;
			to[x]=y,to[y]=x;

			if(x!=y)
			{
				v[y].push_back(x);
				rv[x].push_back(y);
			}
		}
	}

	for(int i=1;i<=n;i++)
		if(!vis[i] && in[i])
		{
			cnt++;
			Solve(i);
		}

	f[0][0]=1;
	for(int i=1;i<=cnt;i++)
	{
		f[i][0]=(f[i-1][1]*a[i][1]+f[i-1][0]*a[i][0])%MOD;
		f[i][1]=(f[i-1][0]*a[i][1]+f[i-1][1]*a[i][0])%MOD;
	}

	int ans=(int)f[cnt][1];
	for(int i=1;i<=n;i++)
		if(!in[i])
		{
			ans<<=1;
			if(ans>MOD)
				ans-=MOD;
		}
	printf("%d\n",ans);
	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <memory.h>
#include <iostream>
#include <math.h>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
const int maxn = 100005;
int ehead[maxn],ecnt,deg[maxn],las[maxn];
struct edge{
	int u,v,next;
}edg[maxn*2];
void add(int u,int v) {
	edg[++ecnt]=(edge){u,v,ehead[u]};
	ehead[u]=ecnt;deg[u]++;
	edg[++ecnt]=(edge){v,u,ehead[v]};
	ehead[v]=ecnt;deg[v]++;
}
int abs(int x){return x>0?x:-x;}
int infomu[maxn];
struct fomu{
	int len,x1,x2;
	void read(int id) {
		scanf("%d %d",&len,&x1);
		if (las[abs(x1)]) add(las[abs(x1)],id);
		else las[abs(x1)]=id;
		infomu[abs(x1)]=1;
		if (len!=1) {
			scanf("%d",&x2);
			if (las[abs(x2)]) add(las[abs(x2)],id);
			else las[abs(x2)]=id;
			infomu[abs(x2)]=1;
		}
	}
	int calc(int fx1,int fx2=0) {
		if (len==1) return x1>0?fx1:fx1^1;
		else return (x1>0?fx1:fx1^1)|(x2>0?fx2:fx2^1);
	}
}fomu[maxn];
bool vis[maxn];int n,m;
LL f[maxn][2][2][2];int cnt;
bool check(int x,int fx,int y,int fy) {
	if (abs(x)!=abs(y)) return true;
	else if (x==0) return true;
	else if (y==0) return true;
	else return fx==fy;
}
pair<LL,LL> dp(int s) {
//	cerr<<"dp"<<s<<endl;
	LL sum0=0,sum1=0;
	int sx1=fomu[s].x1,sx2=fomu[s].x2;
	for (int fsx1=0;fsx1<2;fsx1++)
	for (int fsx2=0;fsx2<fomu[s].len;fsx2++) {
		if (!check(sx1,fsx1,sx2,fsx2)) continue;
		f[1][0][0][0]=f[1][0][1][0]=f[1][1][0][0]=f[1][1][1][0]=0;
		f[1][0][0][1]=f[1][0][1][1]=f[1][1][0][1]=f[1][1][1][1]=0;
		f[1][fsx1][fsx2][fomu[s].calc(fsx1,fsx2)]=1;
		cnt=1;vis[s]=true;int fa=0,cur=s;
		while (true) {
			for (int j=ehead[cur];j;j=edg[j].next)
			if (edg[j].v!=fa&&edg[j].v!=s) {
				fa=cur;vis[cur=edg[j].v]=true;++cnt;
				for (int fx1=0;fx1<2;fx1++)
				for (int fx2=0;fx2<fomu[cur].len;fx2++)
				for (int dat=0;dat<2;dat++) {
					LL sum=0;
					for (int _fx1=0;_fx1<2;_fx1++)
					for (int _fx2=0;_fx2<fomu[fa].len;_fx2++)
					for (int _dat=0;_dat<2;_dat++) {
						int _x1=fomu[fa].x1,x1=fomu[cur].x1;
						int _x2=fomu[fa].x2,x2=fomu[cur].x2;
						if (!check(_x1,_fx1,x1,fx1)) continue;
						if (!check(_x1,_fx1,x2,fx2)) continue;
						if (!check(_x2,_fx2,x1,fx1)) continue;
						if (!check(_x2,_fx2,x2,fx2)) continue;
						if (!check(sx1,fsx1,x1,fx1)) continue;
						if (!check(sx2,fsx2,x1,fx1)) continue;
						if (!check(sx1,fsx1,x2,fx2)) continue;
						if (!check(sx2,fsx2,x2,fx2)) continue;
						if (_dat^fomu[cur].calc(fx1,fx2)==dat)
							sum+=f[cnt-1][_fx1][_fx2][_dat];
					}
					f[cnt][fx1][fx2][dat]=sum%mod;
				}
				goto loop;
			}
			break;loop:;
		}
		for (int fx1=0;fx1<2;fx1++)
		for (int fx2=0;fx2<fomu[cur].len;fx2++) {
			sum0+=f[cnt][fx1][fx2][0];
			sum1+=f[cnt][fx1][fx2][1];
		}
	}
	return pair<LL,LL> (sum0%mod,sum1%mod);
}
LL g[maxn][2];int tot;
int main()
{
	#ifndef ONLINE_JUDGE
		freopen("widow.in","r",stdin);
		freopen("widow.out","w",stdout);
	#endif
	scanf("%d %d",&n,&m);g[0][0]=1;
	for (int i=1;i<=n;i++) fomu[i].read(i);
	for (int i=1;i<=n;i++)
	if (!vis[i]&&deg[i]<2) {
		pair<LL,LL> tmp=dp(i);++tot;
//		cerr<<i<<" "<<tmp.first<<" "<<tmp.second<<endl;
		g[tot][0]=(g[tot-1][0]*tmp.first+g[tot-1][1]*tmp.second)%mod;
		g[tot][1]=(g[tot-1][1]*tmp.first+g[tot-1][0]*tmp.second)%mod;
//		cerr<<g[tot][0]<<" "<<g[tot][1]<<endl;
	}
	for (int i=1;i<=n;i++)
	if (!vis[i]) {
		pair<LL,LL> tmp=dp(i);++tot;
//		cerr<<i<<" "<<tmp.first<<" "<<tmp.second<<endl;
		g[tot][0]=(g[tot-1][0]*tmp.first+g[tot-1][1]*tmp.second)%mod;
		g[tot][1]=(g[tot-1][1]*tmp.first+g[tot-1][0]*tmp.second)%mod;
//		cerr<<g[tot][0]<<" "<<g[tot][1]<<endl;
	}
	LL ans=g[tot][1];
	for (int i=1;i<=m;i++)
		if (!infomu[i]) (ans<<=1)%=mod;
	printf("%I64d\n",ans);
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

typedef long long int ll;

ll modulo=1e9+7;

void anyade(ll &a,ll b)
{
  a+=b;
  a%=modulo;
}

int absolut(int x)
{
  if (x<0) return -x;
  return x;
}

struct arista {
  int v,su,sv,id;
  arista() {}
  arista(int v,int su,int sv,int id):v(v),su(su),sv(sv),id(id) {}
};

const int limite=1000000;

int n,m;
vector<arista> g[limite];
int hayunitaria[limite];
int sunitaria[limite];
int visto[limite];

ll maneras1[2],maneras2[2][2],maneras3[2][2][2];
ll nextmaneras2[2][2],nextmaneras3[2][2][2];

void anyadeunitaria(int u,int su)
{
  if (hayunitaria[u]) {
    if (sunitaria[u]!=su) swap(maneras1[0],maneras1[1]);
    hayunitaria[u]=0;
  } else {
    hayunitaria[u]=1;
    sunitaria[u]=su;
  }
}

void genera(int u,int p);

void genera(int u,arista &a)
{
  for (int i=0;i<2;i++)
    for (int j=0;j<2;j++)
      nextmaneras2[i][j]=0;
  int v=a.v;
  int su=a.su;
  int sv=a.sv;
  for (int valu=0;valu<2;valu++)
    for (int r=0;r<2;r++)
      for (int valv=0;valv<2;valv++)
	anyade(nextmaneras2[valv][r^((valu^su^1)|(valv^sv^1))],maneras2[valu][r]);
  for (int i=0;i<2;i++)
    for (int j=0;j<2;j++)
      maneras2[i][j]=nextmaneras2[i][j];
  genera(v,u);
}

void genera(int u,int p)
{
  visto[u]=1;
  if (int(g[u].size())==0) return;
  if (g[u][0].v==p) {
    if (int(g[u].size())==1) {
      if (hayunitaria[u])
	swap(maneras2[sunitaria[u]][0],maneras2[sunitaria[u]][1]);
      return;
    }
    genera(u,g[u][1]);
  } else {
    genera(u,g[u][0]);
  }
}

void genera(int uini,int u,int id);

void genera(int uini,int u,arista &a)
{
  for (int iini=0;iini<2;iini++)
    for (int i=0;i<2;i++)
      for (int j=0;j<2;j++)
	nextmaneras3[iini][i][j]=0;
  int v=a.v;
  int su=a.su;
  int sv=a.sv;
  int id=a.id;
  for (int iini=0;iini<2;iini++)
    for (int valu=0;valu<2;valu++)
      for (int r=0;r<2;r++)
	for (int valv=0;valv<2;valv++)
	  anyade(nextmaneras3[iini][valv][r^((valu^su^1)|(valv^sv^1))],
		 maneras3[iini][valu][r]);
  for (int iini=0;iini<2;iini++)
    for (int i=0;i<2;i++)
      for (int j=0;j<2;j++)
	maneras3[iini][i][j]=nextmaneras3[iini][i][j];
  genera(uini,v,id);
}

void genera(int uini,int u,int id)
{
  if (visto[u]) return;
  visto[u]=1;
  if (g[u][0].id==id) {
    genera(uini,u,g[u][1]);
  } else {
    genera(uini,u,g[u][0]);
  }
}

int main()
{
  ios::sync_with_stdio(false);
  maneras1[0]=1;
  cin>>m>>n;
  for (int i=1;i<=m;i++) {
    int k;
    cin>>k;
    if (k==1) {
      int u;
      cin>>u;
      anyadeunitaria(absolut(u),u>0);
    } else {
      int u,v;
      cin>>u>>v;
      if (absolut(u)==absolut(v)) {
	if (u==v) anyadeunitaria(absolut(u),u>0);
	else swap(maneras1[0],maneras1[1]);
      } else {
	g[absolut(u)].push_back(arista(absolut(v),u>0,v>0,i));
	g[absolut(v)].push_back(arista(absolut(u),v>0,u>0,i));
      }
    }
  }
  for (int u=1;u<=n;u++) {
    if (not visto[u] and int(g[u].size())<2) {
      //cout<<"caso "<<u<<endl;
      for (int i=0;i<2;i++)
	for (int j=0;j<2;j++)
	  maneras2[i][j]=maneras1[j];
      if (hayunitaria[u])
	swap(maneras2[sunitaria[u]][0],maneras2[sunitaria[u]][1]);
      genera(u,0);
      for (int j=0;j<2;j++) {
	maneras1[j]=0;
	for (int i=0;i<2;i++)
	  anyade(maneras1[j],maneras2[i][j]);
      }
      //cout<<"maneras "<<maneras1[0]<<" "<<maneras1[1]<<endl;
    }
  }
  for (int u=1;u<=n;u++) {
    if (not visto[u]) {
      for (int i=0;i<2;i++)
	for (int j=0;j<2;j++)
	  maneras3[i][i][j]=maneras1[j];
      genera(u,u,0);
      for (int j=0;j<2;j++) {
	maneras1[j]=0;
	for (int i=0;i<2;i++)
	  anyade(maneras1[j],maneras3[i][i][j]);
      }
    }
  }
  cout<<maneras1[1]<<endl;
}


#include <iostream>
#include <vector>

using namespace std;

typedef long long int ll;

ll modulo=1e9+7;

void anyade(ll &a,ll b)
{
  a+=b;
  a%=modulo;
}

int absolut(int x)
{
  if (x<0) return -x;
  return x;
}

struct arista {
  int v,su,sv,id;
  arista() {}
  arista(int v,int su,int sv,int id):v(v),su(su),sv(sv),id(id) {}
};

const int limite=1000000;

int n,m;
vector<arista> g[limite];
int hayunitaria[limite];
int sunitaria[limite];
int visto[limite];

ll maneras1[2],maneras2[2][2],maneras3[2][2][2];
ll nextmaneras2[2][2],nextmaneras3[2][2][2];

void anyadeunitaria(int u,int su)
{
  if (hayunitaria[u]) {
    if (sunitaria[u]!=su) swap(maneras1[0],maneras1[1]);
    hayunitaria[u]=0;
  } else {
    hayunitaria[u]=1;
    sunitaria[u]=su;
  }
}

void genera(int u,int p);

void genera(int u,arista &a)
{
  for (int i=0;i<2;i++)
    for (int j=0;j<2;j++)
      nextmaneras2[i][j]=0;
  int v=a.v;
  int su=a.su;
  int sv=a.sv;
  for (int valu=0;valu<2;valu++)
    for (int r=0;r<2;r++)
      for (int valv=0;valv<2;valv++)
	anyade(nextmaneras2[valv][r^((valu^su^1)|(valv^sv^1))],maneras2[valu][r]);
  for (int i=0;i<2;i++)
    for (int j=0;j<2;j++)
      maneras2[i][j]=nextmaneras2[i][j];
  genera(v,u);
}

void genera(int u,int p)
{
  visto[u]=1;
  if (int(g[u].size())==0) return;
  if (g[u][0].v==p) {
    if (int(g[u].size())==1) {
      if (hayunitaria[u])
	swap(maneras2[sunitaria[u]][0],maneras2[sunitaria[u]][1]);
      return;
    }
    genera(u,g[u][1]);
  } else {
    genera(u,g[u][0]);
  }
}

void genera(int uini,int u,int id);

void genera(int uini,int u,arista &a)
{
  for (int iini=0;iini<2;iini++)
    for (int i=0;i<2;i++)
      for (int j=0;j<2;j++)
	nextmaneras3[iini][i][j]=0;
  int v=a.v;
  int su=a.su;
  int sv=a.sv;
  int id=a.id;
  for (int iini=0;iini<2;iini++)
    for (int valu=0;valu<2;valu++)
      for (int r=0;r<2;r++)
	for (int valv=0;valv<2;valv++)
	  anyade(nextmaneras3[iini][valv][r^((valu^su^1)|(valv^sv^1))],
		 maneras3[iini][valu][r]);
  for (int iini=0;iini<2;iini++)
    for (int i=0;i<2;i++)
      for (int j=0;j<2;j++)
	maneras3[iini][i][j]=nextmaneras3[iini][i][j];
  genera(uini,v,id);
}

void genera(int uini,int u,int id)
{
  if (visto[u]) return;
  visto[u]=1;
  if (g[u][0].id==id) {
    genera(uini,u,g[u][1]);
  } else {
    genera(uini,u,g[u][0]);
  }
}

int main()
{
  ios::sync_with_stdio(false);
  maneras1[0]=1;
  cin>>m>>n;
  for (int i=1;i<=m;i++) {
    int k;
    cin>>k;
    if (k==1) {
      int u;
      cin>>u;
      anyadeunitaria(absolut(u),u>0);
    } else {
      int u,v;
      cin>>u>>v;
      if (absolut(u)==absolut(v)) {
	if (u==v) anyadeunitaria(absolut(u),u>0);
	else swap(maneras1[0],maneras1[1]);
      } else {
	g[absolut(u)].push_back(arista(absolut(v),u>0,v>0,i));
	g[absolut(v)].push_back(arista(absolut(u),v>0,u>0,i));
      }
    }
  }
  for (int u=1;u<=n;u++) {
    if (not visto[u] and int(g[u].size())<2) {
      //cout<<"caso "<<u<<endl;
      for (int i=0;i<2;i++)
	for (int j=0;j<2;j++)
	  maneras2[i][j]=maneras1[j];
      if (hayunitaria[u])
	swap(maneras2[sunitaria[u]][0],maneras2[sunitaria[u]][1]);
      genera(u,0);
      for (int j=0;j<2;j++) {
	maneras1[j]=0;
	for (int i=0;i<2;i++)
	  anyade(maneras1[j],maneras2[i][j]);
      }
      //cout<<"maneras "<<maneras1[0]<<" "<<maneras1[1]<<endl;
    }
  }
  for (int u=1;u<=n;u++) {
    if (not visto[u]) {
      for (int iini=0;iini<2;iini++)
	for (int i=0;i<2;i++)
	  for (int j=0;j<2;j++)
	    maneras3[iini][i][j]=iini==i?maneras1[j]:0;
      genera(u,u,0);
      for (int j=0;j<2;j++) {
	maneras1[j]=0;
	for (int i=0;i<2;i++)
	  anyade(maneras1[j],maneras3[i][i][j]);
      }
    }
  }
  cout<<maneras1[1]<<endl;
}


#include <iostream>
#include <vector>

using namespace std;

typedef long long int ll;

ll modulo=1e9+7;

void anyade(ll &a,ll b)
{
  a+=b;
  a%=modulo;
}

int absolut(int x)
{
  if (x<0) return -x;
  return x;
}

struct arista {
  int v,su,sv;
  arista() {}
  arista(int v,int su,int sv):v(v),su(su),sv(sv) {}
};

const int limite=1000000;

int n,m;
vector<arista> g[limite];
int hayunitaria[limite];
int sunitaria[limite];
int visto[limite];

ll maneras1[2],maneras2[2][2],maneras3[2][2][2];
ll nextmaneras2[2][2],nextmaneras3[2][2][2];

void anyadeunitaria(int u,int su)
{
  if (hayunitaria[u]) {
    if (sunitaria[u]!=su) swap(maneras1[0],maneras1[1]);
    hayunitaria[u]=0;
  } else {
    hayunitaria[u]=1;
    sunitaria[u]=su;
  }
}

void genera(int u,int p);

void genera(int u,arista &a)
{
  for (int i=0;i<2;i++)
    for (int j=0;j<2;j++)
      nextmaneras2[i][j]=0;
  int v=a.v;
  int su=a.su;
  int sv=a.sv;
  for (int valu=0;valu<2;valu++)
    for (int r=0;r<2;r++)
      for (int valv=0;valv<2;valv++)
	anyade(nextmaneras2[valv][r^((valu^su^1)|(valv^sv^1))],maneras2[valu][r]);
  for (int i=0;i<2;i++)
    for (int j=0;j<2;j++)
      maneras2[i][j]=nextmaneras2[i][j];
  genera(v,u);
}

void genera(int u,int p)
{
  visto[u]=1;
  if (int(g[u].size())==0) return;
  if (g[u][0].v==p) {
    if (int(g[u].size())==1) {
      if (hayunitaria[u])
	swap(maneras2[sunitaria[u]][0],maneras2[sunitaria[u]][1]);
      return;
    }
    genera(u,g[u][1]);
  } else {
    genera(u,g[u][0]);
  }
}

void genera(int uini,int u,int p);

void genera(int uini,int u,arista &a)
{
  for (int iini=0;iini<2;iini++)
    for (int i=0;i<2;i++)
      for (int j=0;j<2;j++)
	nextmaneras3[iini][i][j]=0;
  int v=a.v;
  int su=a.su;
  int sv=a.sv;
  for (int iini=0;iini<2;iini++)
    for (int valu=0;valu<2;valu++)
      for (int r=0;r<2;r++)
	for (int valv=0;valv<2;valv++)
	  anyade(nextmaneras3[iini][valv][r^((valu^su^1)|(valv^sv^1))],
		 maneras3[iini][valu][r]);
  for (int iini=0;iini<2;iini++)
    for (int i=0;i<2;i++)
      for (int j=0;j<2;j++)
	maneras3[iini][i][j]=nextmaneras3[iini][i][j];
  genera(uini,v,u);
}

void genera(int uini,int u,int p)
{
  if (visto[u]) return;
  visto[u]=1;
  if (g[u][0].v==p) {
    genera(uini,u,g[u][1]);
  } else {
    genera(uini,u,g[u][0]);
  }
}

int main()
{
  ios::sync_with_stdio(false);
  maneras1[0]=1;
  cin>>m>>n;
  for (int i=0;i<m;i++) {
    int k;
    cin>>k;
    if (k==1) {
      int u;
      cin>>u;
      anyadeunitaria(absolut(u),u>0);
    } else {
      int u,v;
      cin>>u>>v;
      if (absolut(u)==absolut(v)) {
	if (u==v) anyadeunitaria(absolut(u),u>0);
	else swap(maneras1[0],maneras1[1]);
      } else {
	g[absolut(u)].push_back(arista(absolut(v),u>0,v>0));
	g[absolut(v)].push_back(arista(absolut(u),v>0,u>0));
      }
    }
  }
  for (int u=1;u<=n;u++) {
    if (not visto[u] and int(g[u].size())<2) {
      //cout<<"caso "<<u<<endl;
      for (int i=0;i<2;i++)
	for (int j=0;j<2;j++)
	  maneras2[i][j]=maneras1[j];
      if (hayunitaria[u])
	swap(maneras2[sunitaria[u]][0],maneras2[sunitaria[u]][1]);
      genera(u,0);
      for (int j=0;j<2;j++) {
	maneras1[j]=0;
	for (int i=0;i<2;i++)
	  anyade(maneras1[j],maneras2[i][j]);
      }
      //cout<<"maneras "<<maneras1[0]<<" "<<maneras1[1]<<endl;
    }
  }
  for (int u=1;u<=n;u++) {
    if (not visto[u]) {
      for (int i=0;i<2;i++)
	for (int j=0;j<2;j++)
	  maneras3[i][i][j]=maneras1[j];
      genera(u,u,0);
      for (int j=0;j<2;j++) {
	maneras1[j]=0;
	for (int i=0;i<2;i++)
	  anyade(maneras1[j],maneras3[i][i][j]);
      }
    }
  }
  cout<<maneras1[1]<<endl;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
const int N = 100000, M = 100000, P = 1000000007;
struct sp {
  int q, id;
  sp *w;
  bool invIn, invOut;
  sp(int q, sp *w, int id, bool c, bool v) :
    q(q), w(w), id(id) {
    invIn = c;
    invOut = v;
  }
};
sp *a[N];
int edg1[M], edg2[M];
int inv1[M], inv2[M];
int s1[N], s2[N];
bool lok[N];

int line[N], invL[N];
int len;
bool isCircle;
void schLine(int q, int id) {
  lok[q] = 0;
  line[len] = q;
  len++;

  for (sp *c = a[q]; c; c = c->w) {
    if (c->id != id) {
      invL[len - 1] = c->invIn + 2 * c->invOut;
      if (c->q == line[0]) {
        isCircle = 1;
        return;
      }

      schLine(c->q, c->id);

      if (isCircle) {
        return;
      }

    }
  }
}

long long f[2][2], f2[2][2], d[2];
long long ans0 = 1, ans1 = 0;
void calc() {
  int w, e1, e2, e3;
  bool v, v0, v1;
  for (w = 0; w < len - 1; w++) {
    f2[0][0] = f2[0][1] =
    f2[1][0] = f2[1][1] = 0;

    v0 = (invL[w] & 1);
    v1 = (invL[w] >> 1);

    //cout << v0 << " " << v1 << "  !!!\n";

    for (e1 = 0; e1 < 2; e1++) { // ��� ������
      for (e2 = 0; e2 < 2; e2++) {  // ����� �� ����� ���������
        for (e3 = 0; e3 < 2; e3++) { // ��� ��������� �� ����� �����
          v = (e1 | (e3 ^ v0)); // ��������� ���������

          f2[e3 ^ v1][e2 ^ v] += f[e1][e2];
        }
      }
    }
    for (int e = 0; e < 2; e++) {
      for (int r = 0; r < 2; r++) {
        f[e][r] = f2[e][r] % P;
      }
    }
    /*
    for (int e = 0; e < 2; e++) {
      for (int r = 0; r < 2; r++) {
        cout << f[e][r] << " ";
      }
      cout << "\n";
    }
    cout << "*\n";
    */
  }
}
int main() {
  #ifdef Vlad_kv
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif // Vlad_kv
  int q, w, e, e1, e2, e3, r, numEdg;
  long long c0, c1;
  ans0 = 1;
  ans1 = 0;
  bool v0, v1, v;
  cin >> q >> numEdg;
  for (w = 0; w < numEdg; w++) {
    edg1[w] = edg2[w] = -1;
  }
  for (w = 0; w < q; w++) {
    a[w] = 0;
    lok[w] = 1;

    s2[w] = 0;
    scanf("%d%d", &e, &s1[w]);
    r = abs(s1[w]) - 1;
    if (edg1[r] == -1) {
      edg1[r] = w;
      inv1[r] = (s1[w] < 0);
    } else {
      edg2[r] = w;
      inv2[r] = (s1[w] < 0);
    }
    if (e > 1) {
      scanf("%d", &s2[w]);
      r = abs(s2[w]) - 1;
      if (edg1[r] == -1) {
        edg1[r] = w;
        inv1[r] = (s2[w] < 0);
      } else {
        edg2[r] = w;
        inv2[r] = (s2[w] < 0);
      }

    }
  }

  for (w = 0; w < numEdg; w++) {
    if (edg1[w] == -1) {
      ans0 = (ans0 * 2) % P;
      ans1 = (ans1 * 2) % P;
      continue;
    }
    if (edg2[w] != -1) {
      e = edg1[w];
      r = edg2[w];
      if (e == r) {
        s1[e] = s2[e] = 0;
        if (inv1[w] != inv2[w]) {
          swap(ans0, ans1);
          ans0 = (ans0 * 2) % P;
          ans1 = (ans1 * 2) % P;
        } else {
          ans0 = ans1 = (ans0 + ans1) % P;
        }
        continue;
      }
      a[e] = new sp(r, a[e], w, inv1[w], inv2[w]);
      a[r] = new sp(e, a[r], w, inv2[w], inv1[w]);
    }
  }

  for (w = 0; w < q; w++) {
    if (lok[w]) {
      isCircle = 0;
      len = 0;

      schLine(w, -1);

      if (len == 1) {
        if (s2[w] == 0) {
          if (s1[w] != 0) {
            ans0 = ans1 = (ans0 + ans1) % P;
          }
        } else {
          c0 = ans0;
          c1 = ans1;

          ans0 = (c1 * 3 + c0) % P;
          ans1 = (c0 * 3 + c1) % P;
        }
        continue;
      }
      /*
      cout << len << " " << isCircle << "\n";
      for (e = 0; e < len; e++) {
        cout << line[e] + 1 << " ";
      }
      cout << "\n\n";
      */

      if (!isCircle) {
        if (s2[line[0]] == 0) {
          f[0][0] = 1;
          f[0][1] = 0;
          f[1][0] = 0;
          f[1][1] = 0;
        } else {
          f[0][0] = 1;
          f[0][1] = 0;
          f[1][0] = 1;
          f[1][1] = 0;
        }

        calc();

        if (s2[line[len - 1]] == 0) {
          c0 = f[1][0] + f[0][1];
          c1 = f[0][0] + f[1][1];
        } else {
          //cout << "?\n";

          d[0] = d[1] = 0;

          for (e1 = 0; e1 < 2; e1++) {
            for (e2 = 0; e2 < 2; e2++) {
              for (e3 = 0; e3 < 2; e3++) {
                d[(e1 | e3) ^ e2] += f[e1][e2];
              }
            }
          }

          c0 = d[0];
          c1 = d[1];
        }

        c0 %= P;
        c1 %= P;

        //cout << c0 << " " << c1 << " ###\n";

        d[0] = (ans0 * c0 + ans1 * c1) % P;
        d[1] = (ans1 * c0 + ans0 * c1) % P;

        ans0 = d[0];
        ans1 = d[1];
      } else {
        f[0][0] = 0;
        f[0][1] = 0;
        f[1][0] = 0;
        f[1][1] = 0;

        e3 = 0;  // ��� (���) ���������� �� ����� �����
        f[e3 ^ (invL[len - 1] >> 1)][0] = 1;

        calc();

        d[0] = d[1] = 0;

        /// 1
        v0 = (invL[len - 1] & 1);

        for (e1 = 0; e1 < 2; e1++) { // ��� ������
          for (e2 = 0; e2 < 2; e2++) {  // ����� �� ����� ���������
            v = (e1 | (e3 ^ v0)); // ��������� ���������
            d[e2 ^ v] += f[e1][e2];
          }
        }
        /// 1

        //cout << d[0] << " " << d[1] << "   $$$$$\n";

        ///////////////////////

        f[0][0] = 0;
        f[0][1] = 0;
        f[1][0] = 0;
        f[1][1] = 0;

        e3 = 1;  // ��� (���) ���������� �� ����� �����
        f[e3 ^ (invL[len - 1] >> 1)][0] = 1;

        calc();

        /// 2
        v0 = (invL[len - 1] & 1);

        for (e1 = 0; e1 < 2; e1++) { // ��� ������
          for (e2 = 0; e2 < 2; e2++) {  // ����� �� ����� ���������
            v = (e1 | (e3 ^ v0)); // ��������� ���������
            d[e2 ^ v] += f[e1][e2];
          }
        }
        /// 2

        d[0] %= P;
        d[1] %= P;

        c0 = d[0];
        c1 = d[1];

        //cout << c0 << " " << c1 << "    $$$\n";

        d[0] = (ans0 * c0 + ans1 * c1) % P;
        d[1] = (ans1 * c0 + ans0 * c1) % P;

        ans0 = d[0];
        ans1 = d[1];
      }

    }
  }

  cout << ans1;

  return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
const int N = 100000, M = 100000, P = 1000000007;
struct sp {
  int q, id;
  sp *w;
  bool invIn, invOut;
  sp(int q, sp *w, int id, bool c, bool v) :
    q(q), w(w), id(id) {
    invIn = c;
    invOut = v;
  }
};
sp *a[N];
int edg1[M], edg2[M];
int inv1[M], inv2[M];
int s1[N], s2[N];
bool lok[N];

int line[N], invL[N];
int q, len;
bool isCircle;
void schLine(int q, int id) {
  lok[q] = 0;
  line[len] = q;
  len++;

  for (sp *c = a[q]; c; c = c->w) {
    if (c->id != id) {
      invL[len - 1] = c->invIn + 2 * c->invOut;
      if (c->q == line[0]) {
        isCircle = 1;
        return;
      }

      schLine(c->q, c->id);

      if (isCircle) {
        return;
      }

    }
  }
}

long long f[2][2], f2[2][2], d[2];
long long ans0 = 1, ans1 = 0;
void calc() {
  int w, e1, e2, e3;
  bool v, v0, v1;
  for (w = 0; w < len - 1; w++) {
    f2[0][0] = f2[0][1] =
    f2[1][0] = f2[1][1] = 0;

    v0 = (invL[w] & 1);
    v1 = (invL[w] >> 1);

    //cout << v0 << " " << v1 << "  !!!\n";

    for (e1 = 0; e1 < 2; e1++) { // ��� ������
      for (e2 = 0; e2 < 2; e2++) {  // ����� �� ����� ���������
        for (e3 = 0; e3 < 2; e3++) { // ��� ��������� �� ����� �����
          v = (e1 | (e3 ^ v0)); // ��������� ���������

          f2[e3 ^ v1][e2 ^ v] += f[e1][e2];
        }
      }
    }
    for (int e = 0; e < 2; e++) {
      for (int r = 0; r < 2; r++) {
        f[e][r] = f2[e][r] % P;
      }
    }
    /*
    for (int e = 0; e < 2; e++) {
      for (int r = 0; r < 2; r++) {
        cout << f[e][r] << " ";
      }
      cout << "\n";
    }
    cout << "*\n";*/

  }
}

int numInEgd[N];

void l(int t) {
  int w, e, e1, e2, e3;
  long long c0, c1;
  bool v, v0;
  for (w = 0; w < q; w++) {
    if ((lok[w]) && (numInEgd[w] == t)) {
      isCircle = 0;
      len = 0;

      schLine(w, -1);

      if (len == 1) {
        if (s2[w] == 0) {
          if (s1[w] != 0) {
            ans0 = ans1 = (ans0 + ans1) % P;
          }
        } else {
          c0 = ans0;
          c1 = ans1;

          ans0 = (c1 * 3 + c0) % P;
          ans1 = (c0 * 3 + c1) % P;
        }
        continue;
      }
      /*
      cout << len << " " << isCircle << "\n";
      for (e = 0; e < len; e++) {
        cout << line[e] + 1 << " ";
      }
      cout << "\n\n";*/

      if (!isCircle) {
        if (s2[line[0]] == 0) {
          f[0][0] = 1;
          f[0][1] = 0;
          f[1][0] = 0;
          f[1][1] = 0;
        } else {
          f[0][0] = 1;
          f[0][1] = 0;
          f[1][0] = 1;
          f[1][1] = 0;
        }

        calc();

        if (s2[line[len - 1]] == 0) {
          c1 = f[1][0] + f[0][1];
          c0 = f[0][0] + f[1][1];
        } else {
          //cout << "?\n";

          d[0] = d[1] = 0;

          for (e1 = 0; e1 < 2; e1++) {
            for (e2 = 0; e2 < 2; e2++) {
              for (e3 = 0; e3 < 2; e3++) {
                d[(e1 | e3) ^ e2] += f[e1][e2];
              }
            }
          }

          c0 = d[0];
          c1 = d[1];
        }

        c0 %= P;
        c1 %= P;

        //cout << c0 << " " << c1 << " ###\n";

        d[0] = (ans0 * c0 + ans1 * c1) % P;
        d[1] = (ans1 * c0 + ans0 * c1) % P;

        ans0 = d[0];
        ans1 = d[1];
      } else {
        f[0][0] = 0;
        f[0][1] = 0;
        f[1][0] = 0;
        f[1][1] = 0;

        e3 = 0;  // ��� (���) ���������� �� ����� �����
        f[e3 ^ (invL[len - 1] >> 1)][0] = 1;

        calc();

        d[0] = d[1] = 0;

        /// 1
        v0 = (invL[len - 1] & 1);

        for (e1 = 0; e1 < 2; e1++) { // ��� ������
          for (e2 = 0; e2 < 2; e2++) {  // ����� �� ����� ���������
            v = (e1 | (e3 ^ v0)); // ��������� ���������
            d[e2 ^ v] += f[e1][e2];
          }
        }
        /// 1

        //cout << d[0] << " " << d[1] << "   $$$$$\n";

        ///////////////////////

        f[0][0] = 0;
        f[0][1] = 0;
        f[1][0] = 0;
        f[1][1] = 0;

        e3 = 1;  // ��� (���) ���������� �� ����� �����
        f[e3 ^ (invL[len - 1] >> 1)][0] = 1;

        calc();

        /// 2
        v0 = (invL[len - 1] & 1);

        for (e1 = 0; e1 < 2; e1++) { // ��� ������
          for (e2 = 0; e2 < 2; e2++) {  // ����� �� ����� ���������
            v = (e1 | (e3 ^ v0)); // ��������� ���������
            d[e2 ^ v] += f[e1][e2];
          }
        }
        /// 2

        d[0] %= P;
        d[1] %= P;

        c0 = d[0];
        c1 = d[1];

        //cout << c0 << " " << c1 << "    $$$\n";

        d[0] = (ans0 * c0 + ans1 * c1) % P;
        d[1] = (ans1 * c0 + ans0 * c1) % P;

        ans0 = d[0];
        ans1 = d[1];
      }

    }
  }
}

int main() {
  #ifdef Vlad_kv
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif // Vlad_kv
  int w, e, r, numEdg;
  ans0 = 1;
  ans1 = 0;
  cin >> q >> numEdg;
  for (w = 0; w < numEdg; w++) {
    edg1[w] = edg2[w] = -1;
  }
  for (w = 0; w < q; w++) {
    numInEgd[w] = 0;

    a[w] = 0;
    lok[w] = 1;

    s2[w] = 0;
    scanf("%d%d", &e, &s1[w]);
    r = abs(s1[w]) - 1;
    if (edg1[r] == -1) {
      edg1[r] = w;
      inv1[r] = (s1[w] < 0);
    } else {
      edg2[r] = w;
      inv2[r] = (s1[w] < 0);
    }
    if (e > 1) {
      scanf("%d", &s2[w]);
      r = abs(s2[w]) - 1;
      if (edg1[r] == -1) {
        edg1[r] = w;
        inv1[r] = (s2[w] < 0);
      } else {
        edg2[r] = w;
        inv2[r] = (s2[w] < 0);
      }

    }
  }

  for (w = 0; w < numEdg; w++) {
    if (edg1[w] == -1) {
      ans0 = (ans0 * 2) % P;
      ans1 = (ans1 * 2) % P;
      continue;
    }
    if (edg2[w] != -1) {
      e = edg1[w];
      r = edg2[w];
      if (e == r) {
        s1[e] = s2[e] = 0;
        if (inv1[w] != inv2[w]) {
          swap(ans0, ans1);
          ans0 = (ans0 * 2) % P;
          ans1 = (ans1 * 2) % P;
        } else {
          ans0 = ans1 = (ans0 + ans1) % P;
        }
        continue;
      }
      a[e] = new sp(r, a[e], w, inv1[w], inv2[w]);
      a[r] = new sp(e, a[r], w, inv2[w], inv1[w]);
      numInEgd[e]++;
      numInEgd[r]++;
    }
  }

  l(0);
  l(1);
  l(2);

  cout << ans1;

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int P = 1e9 + 7;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); }
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct info {
	int dest, home;
	bool x, y;
};
vector <info> a[MAXN];
int n, m, ans[2], cur[2][2][2];
bool vis[MAXN], res[MAXN][2];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
void work(int pos, int fa) {
	vis[pos] = true;
	for (auto x : a[pos])
		if (x.home != fa) {
			if (vis[x.dest]) {
				int tmp[2] = {0, 0};
				for (int i = 0; i <= 1; i++)
				for (int j = 0; j <= 1; j++)
				for (int k = 0; k <= 1; k++)
					update(tmp[k ^ ((j ^ x.x) || (i ^ x.y))], cur[i][j][k]);
				int res[2] = {0, 0};
				for (int i = 0; i <= 1; i++)
				for (int j = 0; j <= 1; j++)
					update(res[i ^ j], 1ll * tmp[i] * ans[j] % P);
				ans[0] = res[0];
				ans[1] = res[1];
			} else {
				int nxt[2][2][2];
				memset(nxt, 0, sizeof(nxt));
				for (int i = 0; i <= 1; i++)
				for (int j = 0; j <= 1; j++)
				for (int k = 0; k <= 1; k++)
				for (int t = 0; t <= 1; t++)
					update(nxt[i][t][k ^ res[x.dest][t ^ 1] ^ ((j ^ x.x) || (t ^ x.y))], cur[i][j][k]);
				memcpy(cur, nxt, sizeof(nxt));
				work(x.dest, x.home);
			}
			return;
		}
	int tmp[2] = {0, 0};
	for (int i = 0; i <= 1; i++)
	for (int j = 0; j <= 1; j++)
	for (int k = 0; k <= 1; k++)
		update(tmp[k], cur[i][j][k]);
	int res[2] = {0, 0};
	for (int i = 0; i <= 1; i++)
	for (int j = 0; j <= 1; j++)
		update(res[i ^ j], 1ll * tmp[i] * ans[j] % P);
	ans[0] = res[0];
	ans[1] = res[1];
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++) {
		int k, x[3] = {0, 0, 0}; read(k);
		for (int j = 1; j <= k; j++)
			read(x[j]);
		if (k == 1) res[abs(x[1])][x[i] < 0] ^= true;
		else {
			int b = abs(x[1]), c = abs(x[2]);
			a[b].push_back((info) {c, i, x[1] < 0, x[2] < 0});
			a[c].push_back((info) {b, i, x[2] < 0, x[1] < 0});
		}
	}
	ans[0] = 1, ans[1] = 0;
	for (int i = 1; i <= m; i++)
		if (!vis[i] && a[i].size() <= 1) {
			memset(cur, 0, sizeof(cur));
			cur[0][0][res[i][1]] = 1;
			cur[1][1][res[i][0]] = 1;
			work(i, 0);
		}
	for (int i = 1; i <= m; i++)
		if (!vis[i]) {
			memset(cur, 0, sizeof(cur));
			cur[0][0][res[i][1]] = 1;
			cur[1][1][res[i][0]] = 1;
			work(i, 0);
		}
	cout << ans[1] << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int P = 1e9 + 7;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); }
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct info {
	int dest, home;
	bool x, y;
};
vector <info> a[MAXN];
int n, m, ans[2], cur[2][2][2];
bool vis[MAXN], res[MAXN][2];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
void work(int pos, int fa) {
	vis[pos] = true;
	for (auto x : a[pos])
		if (x.home != fa) {
			if (vis[x.dest]) {
				int tmp[2] = {0, 0};
				for (int i = 0; i <= 1; i++)
				for (int j = 0; j <= 1; j++)
				for (int k = 0; k <= 1; k++)
					update(tmp[k ^ ((j ^ x.x) || (i ^ x.y))], cur[i][j][k]);
				int res[2] = {0, 0};
				for (int i = 0; i <= 1; i++)
				for (int j = 0; j <= 1; j++)
					update(res[i ^ j], 1ll * tmp[i] * ans[j] % P);
				ans[0] = res[0];
				ans[1] = res[1];
			} else {
				int nxt[2][2][2];
				memset(nxt, 0, sizeof(nxt));
				for (int i = 0; i <= 1; i++)
				for (int j = 0; j <= 1; j++)
				for (int k = 0; k <= 1; k++)
				for (int t = 0; t <= 1; t++)
					update(nxt[i][t][k ^ res[x.dest][t ^ 1] ^ ((j ^ x.x) || (t ^ x.y))], cur[i][j][k]);
				memcpy(cur, nxt, sizeof(nxt));
				work(x.dest, x.home);
			}
			return;
		}
	int tmp[2] = {0, 0};
	for (int i = 0; i <= 1; i++)
	for (int j = 0; j <= 1; j++)
	for (int k = 0; k <= 1; k++)
		update(tmp[k], cur[i][j][k]);
	int res[2] = {0, 0};
	for (int i = 0; i <= 1; i++)
	for (int j = 0; j <= 1; j++)
		update(res[i ^ j], 1ll * tmp[i] * ans[j] % P);
	ans[0] = res[0];
	ans[1] = res[1];
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++) {
		int k, x[3] = {0, 0, 0}; read(k);
		for (int j = 1; j <= k; j++)
			read(x[j]);
		if (k == 1) res[abs(x[1])][x[1] < 0] ^= true;
		else {
			int b = abs(x[1]), c = abs(x[2]);
			a[b].push_back((info) {c, i, x[1] < 0, x[2] < 0});
			a[c].push_back((info) {b, i, x[2] < 0, x[1] < 0});
		}
	}
	ans[0] = 1, ans[1] = 0;
	for (int i = 1; i <= m; i++)
		if (!vis[i] && a[i].size() <= 1) {
			memset(cur, 0, sizeof(cur));
			cur[0][0][res[i][1]] = 1;
			cur[1][1][res[i][0]] = 1;
			work(i, 0);
		}
	for (int i = 1; i <= m; i++)
		if (!vis[i]) {
			memset(cur, 0, sizeof(cur));
			cur[0][0][res[i][1]] = 1;
			cur[1][1][res[i][0]] = 1;
			work(i, 0);
		}
	cout << ans[1] << endl;
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
#define int long long
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
const int MOD=1e9+7;
int nedge=-1,p[200010],c[200010],nex[200010],head[200010];
bool vis[100010];
int g[100010],n,m,ans1=0,ans0=1,cnt,kkk,u,v,pdu,pdv,f[100010][2][2];
inline void addedge(int x,int y,int z){
	p[++nedge]=y;c[nedge]=z;nex[nedge]=head[x];head[x]=nedge;
}
inline void add(int x,int y,int v1,int v2){
	addedge(x,y,v1);addedge(y,x,v2);
}
inline void dfs(int x,int K){
	cnt-=2;vis[x]=1;
	for(int k=head[x];k>=0;k=nex[k]){
		cnt++;if(p[k]==x)cnt++;
		if(!vis[p[k]])dfs(p[k],k);
		else if(k!=(K^1))u=x,v=p[k],kkk=k;
	}
}
inline bool check(int x,int y,int z){
	if((z&2)==0)x^=1;
	if((z&1)==0)y^=1;
	return x|y;
}
inline void dp(int x,int fa){
	for(int k=head[x];k>=0;k=nex[k])if(p[k]!=fa&&(k^kkk)&&(k^kkk^1))dp(p[k],x);
	memset(f[x],0,sizeof f[x]);
	for(int r=0;r<2;r++){
		if(x==u&&r!=pdu)continue;
		if(x==v&&r!=pdv)continue;
		int a0=1,a1=0;
		for(int k=head[x];k>=0;k=nex[k])if(p[k]!=fa&&(k^kkk)&&(k^kkk^1)){
			int to=p[k];int an0=a0,an1=a1;a0=a1=0;
			for(int R=0;R<2;R++){
				int A=f[to][R][0],B=f[to][R][1];
				if(check(r,R,c[k]))swap(A,B);
				a0=(a0+A*an0+B*an1)%MOD;
				a1=(a1+A*an1+B*an0)%MOD;
			}
		}
		if(g[x]&(1<<r))swap(a0,a1);
		f[x][r][0]=(f[x][r][0]+a0)%MOD;
		f[x][r][1]=(f[x][r][1]+a1)%MOD;
	}
}
inline void work(int x){
	cnt=0;kkk=-100;int a0=0,a1=0;dfs(x,-1);
	if(kkk==-100){
		v=0;u=x;pdu=0;pdv=1;dp(x,0);
		a0=(a0+f[x][0][0]+f[x][1][0])%MOD;
		a1=(a1+f[x][0][1]+f[x][1][1])%MOD;
		pdu=1;dp(x,0);
		a0=(a0+f[x][0][0]+f[x][1][0])%MOD;
		a1=(a1+f[x][0][1]+f[x][1][1])%MOD;
	}else{
		for(pdu=0;pdu<2;pdu++)
			for(pdv=0;pdv<2;pdv++){
				dp(u,0);
				if(check(pdu,pdv,c[kkk]))swap(f[u][0][0],f[u][0][1]),swap(f[u][1][0],f[u][1][1]);
				a0=(a0+f[u][0][0]+f[u][1][0])%MOD;
				a1=(a1+f[u][0][1]+f[u][1][1])%MOD;
			}
	}
	int k0=ans0,k1=ans1;
	ans0=(k0*a0+k1*a1)%MOD;
	ans1=(k0*a1+k1*a0)%MOD;
}
signed main()
{
	m=read();n=read();
	memset(nex,-1,sizeof nex);memset(head,-1,sizeof head);
	for(int i=1;i<=m;i++){
		int op=read();
		if(op==1){
			int x=read();
			if(x>0)g[x]|=2;
			else g[-x]|=1;
		}else{
			int x=read(),y=read();
			if(x<0&&y<0)add(-x,-y,0,0);
			if(x<0&&y>0)add(-x,y,1,2);
			if(x>0&&y<0)add(x,-y,2,1);
			if(x>0&&y>0)add(x,y,3,3);
		}
	}
	for(int i=1;i<=n;i++)if(!vis[i])work(i);
	printf("%lld",ans1);
	return 0;
}


#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<memory.h>
#include<cassert>
#include<string>
using namespace std;
#define mod 1000000007
#define ll long long
#define N 110000
int n,m,tot,neg;
int head[N],nex[N<<1],to[N<<1],val[N<<1];
int vis[N],cnt[N],a[N],b[N],use[N],u1[N<<1];
int st[N][2],top,ans,du[N],f[N][2][2],g[N][2][2][2],d[N][2];
int e[N],sum;
void add(int x,int y,int z)
{
    tot++;
    nex[tot]=head[x];head[x]=tot;
    to[tot]=y;val[tot]=z;
}
void dfs(int x)
{
    if(use[x])return;
    use[x]=1;
    for(int i=head[x];i;i=nex[i])
        if(!u1[i])
        {
            e[++sum]=i;
            u1[i]=u1[i^1]=1;
            dfs(to[i]);
        }
}
int get(int v,int x,int y)
{
    if(to[v]!=abs(b[val[v]]))swap(x,y);
    int t=val[v];
    if(a[t]<0)x^=1;
    if(b[t]<0)y^=1;
    return x|y;
}
int main()
{
//  freopen("tt.in","r",stdin);
    scanf("%d%d",&n,&m);tot=1;
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&cnt[i]);
        if(cnt[i]==1)
        {
            scanf("%d",&a[i]);
            if(vis[abs(a[i])])
            {
                st[top][0]=st[top][1]=0;
                top--;(ans*=2)%=mod;
                continue;
            }
            vis[abs(a[i])]=a[i];
            if(!du[abs(a[i])])st[++top][0]=st[top][1]=1;
        }
        if(cnt[i]==2)
        {
            scanf("%d%d",&a[i],&b[i]);
            if(a[i]==-b[i])
            {
                neg++,vis[abs(a[i])]=1;
                (ans*=2)%=mod;
            }
            else
            {
                int a1=abs(a[i]),b1=abs(b[i]);
                if(a1==b1)vis[a1]=1,st[++top][0]=st[top][1]=1;
                else
                {
                    add(a1,b1,i);add(b1,a1,i);
                    du[a1]++;du[b1]++;
                    if(vis[a1])st[top][0]=st[top][1]=0,top--;
                    if(vis[b1])st[top][0]=st[top][1]=0,top--;
                }
            }
        }
    }
    for(int now=1;now<=m;now++)
        if(!use[now]&&du[now]!=2)
        {
            if(!du[now]&&!vis[now])(ans*=2)%=mod;
            else if(!du[now])continue;
            else
            {
                sum=0;dfs(now);
                for(int i=1;i<=sum;i++)
                    memset(f[i],0,sizeof(f[i]));
                if(vis[now])
                {
                    if(vis[now]<0)
                    {
                        f[1][0][get(e[1],0,0)^1]++;
                        f[1][1][get(e[1],0,1)^1]++;
                        f[1][0][get(e[1],1,0)]++;
                        f[1][1][get(e[1],1,1)]++;
                    }
                    else
                    {
                        f[1][0][get(e[1],0,0)]++;
                        f[1][1][get(e[1],0,1)]++;
                        f[1][0][get(e[1],1,0)^1]++;
                        f[1][1][get(e[1],1,1)^1]++;
                    }
                }
                else
                {
                    f[1][0][get(e[1],0,0)]++;
                    f[1][1][get(e[1],0,1)]++;
                    f[1][0][get(e[1],1,0)]++;
                    f[1][1][get(e[1],1,1)]++;
                }
                for(int i=1;i<sum;i++)
                    for(int j=0;j<=1;j++)
                        for(int k=0;k<=1;k++)
                            for(int t=0;t<=1;t++)
                            {
                                (f[i+1][j][t^get(e[i+1],k,j)]+=f[i][k][t])%=mod;
                            }
                top++;
                for(int i=0;i<=1;i++)
                {
                    for(int j=0,t;j<=1;j++)
                    {
                        if(t=vis[to[e[sum]]])
                            (st[top][j^i^(t<0)]+=f[sum][i][j])%=mod;
                        else (st[top][j]+=f[sum][i][j])%=mod;
                    }
                }
            }
        }
    for(int now=1;now<=m;now++)
        if(!use[now]&&du[now]==2)
        {
            sum=0;dfs(now);
            for(int i=1;i<=sum;i++)
                memset(g[i],0,sizeof(g[i]));
            g[1][0][0][get(e[1],0,0)]++;
            g[1][0][1][get(e[1],0,1)]++;
            g[1][1][0][get(e[1],1,0)]++;
            g[1][1][1][get(e[1],1,1)]++;
            for(int i=1;i<sum-1;i++)
                for(int j=0;j<=1;j++)
                    for(int k=0;k<=1;k++)
                        for(int t=0;t<=1;t++)
                            for(int w=0;w<=1;w++)
                            {
                                (g[i+1][j][t][w^get(e[i+1],k,t)]+=g[i][j][k][w])%=mod;
                            }
            top++;
            for(int i=0;i<=1;i++)
                for(int j=0;j<=1;j++)
                    for(int k=0;k<=1;k++)
                    {
                        (st[top][get(e[sum],j,i)^k]+=g[sum-1][i][j][k])%=mod;
                    }

        }
    d[0][0]=ans;
    for(int i=1;i<=top;i++)
        for(int j=0;j<=1;j++)
            for(int k=0;k<=1;k++)
                (d[i][j^k]+=(ll)d[i-1][j]*st[i][k]%mod)%=mod;

    if(neg&1)printf("%d\n",d[top][0]);
    else printf("%d\n",d[top][1]);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;

const int N = 100010, mod = 1000000000 + 7;

struct edge{ int to, pre, c; }e[N << 1]; int u[N], l = 1;
void ins(int a, int b, int c) { e[++l] = (edge){b, u[a], c}, u[a] = l; }
#define v e[i].to
#define ec e[i].c
#define reg(i,a) for(int i = u[a]; i; i = e[i].pre)

int ans[2], f[N][2][2];

int fr;
int nxt(int x) { reg(i,x) if (i ^ fr ^ 1 && x != v) { fr = i; return v; } return 0; }

int chain_S;
bool vis[N];
bool check(int x) {
	int S = x; fr = 0; vis[0] = true; int len = 0;
	while (!vis[x]) vis[x] = true, x = nxt(chain_S = x), len++;
	return x == S;
}

int c[N], L = 0, w[N];

int calc(int w, int a, int b) {
	if (w == 10) return 0;
	if (!(w & 2)) a = !a; if (!(w & 1)) b = !b;
	return a | b;
}

int pre[N];

bool single(int x) {
	reg(i,x) if (v != x) return false;
	return true;
}

int main() {
	freopen("equation.in","r",stdin);
//	freopen("equation.out","w",stdout);
	int m, n; scanf("%d%d",&m,&n); rep(i,1,n) vis[i] = true;
	rep(i,1,m) {
		int k, x, y; scanf("%d",&k);
		if (k == 1) scanf("%d",&x), y = x;
		else scanf("%d%d",&x,&y);
		ins(ab(x), ab(y), (int(x > 0) << 1) | int(y > 0));
		if (ab(x) != ab(y)) ins(ab(y), ab(x), (int(y > 0) << 1) | int(x > 0)); else l++;
		vis[ab(x)] = false, vis[ab(y)] = false;
	}
	ans[0] = 1; rep(i,1,n) if (vis[i]) ans[0] = (ans[0] << 1) % mod;
	rep(S,1,n) if (!vis[S]) {
		bool cir = check(S), sd = single(S);
		if (sd) {
			int tmp[2] = {ans[0], ans[1]}; ans[0] = ans[1] = 0;
			rep(sx,0,1) {
				int tot = 0;
				reg(i,S) tot ^= calc(ec, sx, sx);
				rep(j,0,1) (ans[j ^ tot] += tmp[j]) %= mod;
			}
		} else if (cir) {
			//circle
			fr = 0; c[L = 1] = S; int x = nxt(S); w[2] = e[fr].c;
			for(;x != S; x = nxt(x), w[L + 1] = e[fr].c) c[++L] = x;
			rep(sx, 0, 1) {
				rep(i,1,L) rep(j,0,1) rep(k,0,1) f[i][j][k] = 0;
				f[1][sx][0] = 1;
				rep(i,2,L) rep(j,0,1) rep(k,0,1) if (f[i - 1][j][k])
					rep(t,0,1) (f[i][t][k ^ calc(w[i], j, t)] += f[i - 1][j][k]) %= mod;

				int tmp[2] = {ans[0], ans[1]}; ans[0] = ans[1] = 0;
				rep(j,0,1) rep(k,0,1) if (f[L][j][k])
					rep(t,0,1) (ans[t ^ calc(w[L + 1], j, sx) ^ k] += 1LL * tmp[t] * f[L][j][k]) %= mod;
			}
		} else {
			//chain
			int x = chain_S; L = 0; int Sw = 10, Tw = 10; fr = 0;
			reg(i,x) if (v == x) fr = i, Sw = ec; pre[0] = S;
			for(;pre[x] != S; x = nxt(x), w[L + 1] = e[fr].c) pre[x] = S, c[++L] = x;
			int T = c[L]; reg(i,T) if (v == T) Tw = ec;
			rep(i,1,L) rep(j,0,1) rep(k,0,1) f[i][j][k] = 0;
			f[1][0][calc(Sw, 0, 0)]++, f[1][1][calc(Sw, 1, 1)]++;
			rep(i,2,L) rep(j,0,1) rep(k,0,1) if (f[i - 1][j][k])
				rep(t,0,1) (f[i][t][k ^ calc(w[i], j, t)] += f[i - 1][j][k]) %= mod;
			int tmp[2] = {ans[0], ans[1]}; ans[0] = ans[1] = 0;
			rep(j,0,1) rep(k,0,1) if (f[L][j][k])
				rep(t,0,1) (ans[t ^ calc(Tw, j, j) ^ k] += 1LL * tmp[t] * f[L][j][k]) %= mod;
			rep(i,1,L) vis[c[i]] = true;
		}
	}
	printf("%d\n",ans[1]);
	return 0;
}