Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import sys
import numpy as np
import itertools
input = sys.stdin.readline
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(M+1)]


# In[ ]:


"""
5 2
3 1 2 5
2 2 3
1 0
"""


# In[4]:


#print(l)
import numpy as np


# In[9]:


s = range(N)
cnt = 0
# N個がonになる
for e in range(1, N+1):
    c = list(itertools.combinations(s,e))# N個onになる通り
    o = list(range(N))
    for b in c:
        #print(b)
        a = np.zeros((N))
        for d in b:
            a[d] = 1
        #print(a)
        for i in range(M):
            sum_ = 0
            for j in range(l[i][0]):
                ind = l[i][j+1]-1
                #print(ind)
                sum_ += a[ind]
            o[i] = sum_%2==l[-1][i]
        if np.all(o):
            cnt += 1
#0個on
o = list(range(N))
a = np.zeros((N))
for i in range(M):
    sum_ = 0
    for j in range(l[i][0]):
        ind = l[i][j+1]-1
        sum_ += a[ind]
    o[i] = sum_%2==l[-1][i]
if np.all(o):
    cnt += 1
print(cnt)


# In[ ]:


"""
2 2
2 1 2
1 2
0 1
"""



Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[12]:


import sys
#import numpy as np
import itertools
input = sys.stdin.readline
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(M+1)]


# In[ ]:


"""
5 2
3 1 2 5
2 2 3
1 0
"""


# In[4]:


#print(l)
#import numpy as np


# In[15]:


cnt = 0
#print(itertools.product(range(0, 2), repeat=N))
for on in itertools.product(range(0, 2), repeat=N):
    for i in range(M):
        sum_ = 0
        for j in range(l[i][0]):
            ind = l[i][j+1]-1
            sum_ += on[ind]
        if sum_%2 != l[-1][i]:
            break
    else:
        cnt += 1
print(cnt)

"""
s = range(N)
cnt = 0
# N個がonになる
for e in range(1, N+1):
    c = list(itertools.combinations(s,e))# N個onになる通り
    o = list(range(N))
    for b in c:
        #print(b)
        a = np.zeros((N))
        for d in b:
            a[d] = 1
        #print(a)
        for i in range(M):
            sum_ = 0
            for j in range(l[i][0]):
                ind = l[i][j+1]-1
                #print(ind)
                sum_ += a[ind]
            o[i] = sum_%2==l[-1][i]
        if np.all(o):
            cnt += 1
#0個on
o = list(range(N))
a = np.zeros((N))
for i in range(M):
    sum_ = 0
    for j in range(l[i][0]):
        ind = l[i][j+1]-1
        sum_ += a[ind]
    o[i] = sum_%2==l[-1][i]
if np.all(o):
    cnt += 1
print(cnt)
"""


# In[ ]:


"""
2 2
2 1 2
1 2
0 1
"""

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import sys
import numpy as np
import itertools
input = sys.stdin.readline
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(M+1)]


# In[ ]:


"""
5 2
3 1 2 5
2 2 3
1 0
"""


# In[4]:


#print(l)
import numpy as np


# In[9]:


s = range(N)
cnt = 0
# N個がonになる
for e in range(1, N+1):
    c = list(itertools.combinations(s,e))# N個onになる通り
    o = list(range(N))
    for b in c:
        #print(b)
        a = np.zeros((N))
        for d in b:
            a[d] = 1
        #print(a)
        for i in range(M):
            sum_ = 0
            for j in range(l[i][0]):
                ind = l[i][j+1]-1
                #print(ind)
                sum_ += a[ind]
            o[i] = sum_%2==l[-1][i]
        if np.all(o):
            cnt += 1
#0個on
o = list(range(N))
for i in range(M):
    sum_ = 0
    for j in range(l[i][0]):
        ind = l[i][j+1]-1
        sum_ += a[ind]
    o[i] = sum_%2==l[-1][i]
if np.all(o):
    cnt += 1
print(cnt)


# In[ ]:


"""
2 2
2 1 2
1 2
0 1
"""



Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[12]:


import sys
#import numpy as np
import itertools
input = sys.stdin.readline
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(M+1)]


# In[ ]:


"""
5 2
3 1 2 5
2 2 3
1 0
"""


# In[4]:


#print(l)
#import numpy as np


# In[15]:


cnt = 0
#print(itertools.product(range(0, 2), repeat=N))
for on in itertools.product(range(0, 2), repeat=N):
    for i in range(M):
        sum_ = 0
        for j in range(l[i][0]):
            ind = l[i][j+1]-1
            sum_ += on[ind]
        if sum_%2 != l[-1][i]:
            break
    else:
        cnt += 1
print(cnt)

"""
s = range(N)
cnt = 0
# N個がonになる
for e in range(1, N+1):
    c = list(itertools.combinations(s,e))# N個onになる通り
    o = list(range(N))
    for b in c:
        #print(b)
        a = np.zeros((N))
        for d in b:
            a[d] = 1
        #print(a)
        for i in range(M):
            sum_ = 0
            for j in range(l[i][0]):
                ind = l[i][j+1]-1
                #print(ind)
                sum_ += a[ind]
            o[i] = sum_%2==l[-1][i]
        if np.all(o):
            cnt += 1
#0個on
o = list(range(N))
a = np.zeros((N))
for i in range(M):
    sum_ = 0
    for j in range(l[i][0]):
        ind = l[i][j+1]-1
        sum_ += a[ind]
    o[i] = sum_%2==l[-1][i]
if np.all(o):
    cnt += 1
print(cnt)
"""


# In[ ]:


"""
2 2
2 1 2
1 2
0 1
"""

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import sys
import numpy as np
import itertools
input = sys.stdin.readline
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(M+1)]


# In[ ]:


"""
5 2
3 1 2 5
2 2 3
1 0
"""


# In[4]:


#print(l)
import numpy as np


# In[7]:


s = range(N)
cnt = 0
for e in range(1, N+1):
    c = list(itertools.combinations(s,e))
    #print(c)
    #print(c)
    o = list(range(N))
    for b in c:
        #print(b)
        a = np.zeros((N))
        for d in b:
            a[d] = 1
        #print(a)
        for i in range(M):
            sum_ = 0
            for j in range(len(l[i][1:])):
                ind = l[i][j+1]-1
                #print(ind)
                sum_ += a[ind]
            o[i] = sum_%2==l[-1][i]
        if np.all(o):
            cnt += 1
print(cnt)


# In[ ]:


"""
2 2
2 1 2
1 2
0 1
"""



Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[12]:


import sys
#import numpy as np
import itertools
input = sys.stdin.readline
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(M+1)]


# In[ ]:


"""
5 2
3 1 2 5
2 2 3
1 0
"""


# In[4]:


#print(l)
#import numpy as np


# In[15]:


cnt = 0
#print(itertools.product(range(0, 2), repeat=N))
for on in itertools.product(range(0, 2), repeat=N):
    for i in range(M):
        sum_ = 0
        for j in range(l[i][0]):
            ind = l[i][j+1]-1
            sum_ += on[ind]
        if sum_%2 != l[-1][i]:
            break
    else:
        cnt += 1
print(cnt)

"""
s = range(N)
cnt = 0
# N個がonになる
for e in range(1, N+1):
    c = list(itertools.combinations(s,e))# N個onになる通り
    o = list(range(N))
    for b in c:
        #print(b)
        a = np.zeros((N))
        for d in b:
            a[d] = 1
        #print(a)
        for i in range(M):
            sum_ = 0
            for j in range(l[i][0]):
                ind = l[i][j+1]-1
                #print(ind)
                sum_ += a[ind]
            o[i] = sum_%2==l[-1][i]
        if np.all(o):
            cnt += 1
#0個on
o = list(range(N))
a = np.zeros((N))
for i in range(M):
    sum_ = 0
    for j in range(l[i][0]):
        ind = l[i][j+1]-1
        sum_ += a[ind]
    o[i] = sum_%2==l[-1][i]
if np.all(o):
    cnt += 1
print(cnt)
"""


# In[ ]:


"""
2 2
2 1 2
1 2
0 1
"""