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

# In[15]:


N,M = map(int, input().split())
ks = []
for _ in range(M):
    ks.append(list(map(int, input().split())))
p = list(map(int, input().split()))


# In[16]:


ans = 0
for s in range(2**N):
    s_bit = format(s,"010b")
    for i,item in enumerate(ks):
        cnt = 0
        for x in item[1:]:
            if s_bit[10-x] == "1":
                cnt += 1
        if cnt%2 != p[i]:
            break
    else:
        ans += 1
        continue
print(ans)


# In[ ]:



 N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M ks = [] ks [] for _ in range(M):
    ks.append(list(map(int, input().split()))) _ range(M) range M ks.append(list(map(int, input().split()))) ks.append ks append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for s in range(2**N):
    s_bit = format(s,"010b")
    for i,item in enumerate(ks):
        cnt = 0
        for x in item[1:]:
            if s_bit[10-x] == "1":
                cnt += 1
        if cnt%2 != p[i]:
            break
    else:
        ans += 1
        continue s range(2**N) range 2**N 2 N s_bit = format(s,"010b") s_bit format(s,"010b") format s "010b" for i,item in enumerate(ks):
        cnt = 0
        for x in item[1:]:
            if s_bit[10-x] == "1":
                cnt += 1
        if cnt%2 != p[i]:
            break
    else:
        ans += 1
        continue i item enumerate(ks) enumerate ks cnt = 0 cnt 0 for x in item[1:]:
            if s_bit[10-x] == "1":
                cnt += 1
         x item[1:] item 1: 1 if s_bit[10-x] == "1":
                cnt += 1
         s_bit[10-x] == "1" s_bit[10-x] s_bit 10-x 10 x "1" cnt += 1 cnt 1 if cnt%2 != p[i]:
            break
     cnt%2 != p[i] cnt%2 cnt 2 p[i] p i break ans += 1 ans 1 continue print(ans) print ans cnt += 1 1 cnt ks = [] [] ks p = list(map(int, input().split())) list(map(int, input().split())) p ans = 0 0 ans cnt = 0 0 cnt ans += 1 1 ans N,M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M s_bit = format(s,"010b") format(s,"010b") s_bit
#!/usr/bin/env python
# coding: utf-8

# In[15]:


N,M = map(int, input().split())
ks = []
for _ in range(M):
    ks.append(list(map(int, input().split())))
p = list(map(int, input().split()))


# In[16]:


ans = 0
for s in range(2**N):
    s_bit = format(s,"010b")
    for i,item in enumerate(ks):
        cnt = 0
        for x in item[1:]:
            if s_bit[10-x] == "1":
                cnt += 1
        if cnt%2 != p[i]:
            break
    else:
        ans += 1
        continue
print(ans)


# In[ ]:




