#import math
import itertools
#import numpy as np
#from collections import deque


INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n,m=INTM()
    cnct=[]
    for i in range(m):
        temp=LIST()
        temp=temp[1:]
        cnct.append(temp)
    ps=LIST()
    ans=0
    
    for bit in range(2**n):
        check=[0]*m
        for i in range(n):
            if (bit>>i)&1:
                for k in range(m):
                    if i+1 in cnct[k]:
                        check[k]+=1
        
        flg=True
        for k in range(m):
            if check[k]%2!=ps[k]:
                flg=False
        
        if flg:
            ans+=1
    
    print(ans)


if __name__=='__main__':
    do() import itertools itertools INT = lambda: int(input()) INT lambda: int(input()) int(input()) int input() input INTM = lambda: map(int,input().split()) INTM lambda: map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split STRM = lambda: map(str,input().split()) STRM lambda: map(str,input().split()) map(str,input().split()) map str input().split() ().split () input split STR = lambda: str(input()) STR lambda: str(input()) str(input()) str input() input LIST = lambda: list(map(int,input().split())) LIST lambda: list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split LISTS = lambda: list(map(str,input().split())) LISTS lambda: list(map(str,input().split())) list(map(str,input().split())) list map(str,input().split()) map str input().split() ().split () input split def do():
    n,m=INTM()
    cnct=[]
    for i in range(m):
        temp=LIST()
        temp=temp[1:]
        cnct.append(temp)
    ps=LIST()
    ans=0
    
    for bit in range(2**n):
        check=[0]*m
        for i in range(n):
            if (bit>>i)&1:
                for k in range(m):
                    if i+1 in cnct[k]:
                        check[k]+=1
        
        flg=True
        for k in range(m):
            if check[k]%2!=ps[k]:
                flg=False
        
        if flg:
            ans+=1
    
    print(ans) do n,m=INTM() n INTM() INTM m cnct=[] cnct [] for i in range(m):
        temp=LIST()
        temp=temp[1:]
        cnct.append(temp)
     i range(m) range m temp=LIST() temp LIST() LIST temp=temp[1:] temp temp[1:] temp 1: 1 cnct.append(temp) cnct.append cnct append temp ps=LIST() ps LIST() LIST ans=0 ans 0 for bit in range(2**n):
        check=[0]*m
        for i in range(n):
            if (bit>>i)&1:
                for k in range(m):
                    if i+1 in cnct[k]:
                        check[k]+=1
        
        flg=True
        for k in range(m):
            if check[k]%2!=ps[k]:
                flg=False
        
        if flg:
            ans+=1
    
     bit range(2**n) range 2**n 2 n check=[0]*m check [0]*m [0] 0 m for i in range(n):
            if (bit>>i)&1:
                for k in range(m):
                    if i+1 in cnct[k]:
                        check[k]+=1
        
         i range(n) range n if (bit>>i)&1:
                for k in range(m):
                    if i+1 in cnct[k]:
                        check[k]+=1
        
         (bit>>i)&1 bit>>i bit i 1 for k in range(m):
                    if i+1 in cnct[k]:
                        check[k]+=1
        
         k range(m) range m if i+1 in cnct[k]:
                        check[k]+=1
        
         i+1 in cnct[k] i+1 i 1 cnct[k] cnct k check[k]+=1 check[k] check k 1 flg=True flg True for k in range(m):
            if check[k]%2!=ps[k]:
                flg=False
        
         k range(m) range m if check[k]%2!=ps[k]:
                flg=False
        
         check[k]%2!=ps[k] check[k]%2 check[k] check k 2 ps[k] ps k flg=False flg False if flg:
            ans+=1
    
     flg ans+=1 ans 1 print(ans) print ans if __name__=='__main__':
    do() __name__=='__main__' __name__ '__main__' do() do INT = lambda: int(input()) lambda: int(input()) INT def do():
    n,m=INTM()
    cnct=[]
    for i in range(m):
        temp=LIST()
        temp=temp[1:]
        cnct.append(temp)
    ps=LIST()
    ans=0
    
    for bit in range(2**n):
        check=[0]*m
        for i in range(n):
            if (bit>>i)&1:
                for k in range(m):
                    if i+1 in cnct[k]:
                        check[k]+=1
        
        flg=True
        for k in range(m):
            if check[k]%2!=ps[k]:
                flg=False
        
        if flg:
            ans+=1
    
    print(ans) def do():
    n,m=INTM()
    cnct=[]
    for i in range(m):
        temp=LIST()
        temp=temp[1:]
        cnct.append(temp)
    ps=LIST()
    ans=0
    
    for bit in range(2**n):
        check=[0]*m
        for i in range(n):
            if (bit>>i)&1:
                for k in range(m):
                    if i+1 in cnct[k]:
                        check[k]+=1
        
        flg=True
        for k in range(m):
            if check[k]%2!=ps[k]:
                flg=False
        
        if flg:
            ans+=1
    
    print(ans) do STR = lambda: str(input()) lambda: str(input()) STR INTM = lambda: map(int,input().split()) lambda: map(int,input().split()) INTM STRM = lambda: map(str,input().split()) lambda: map(str,input().split()) STRM LISTS = lambda: list(map(str,input().split())) lambda: list(map(str,input().split())) LISTS LIST = lambda: list(map(int,input().split())) lambda: list(map(int,input().split())) LIST
#import math
import itertools
#import numpy as np
#from collections import deque


INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n,m=INTM()
    cnct=[]
    for i in range(m):
        temp=LIST()
        temp=temp[1:]
        cnct.append(temp)
    ps=LIST()
    ans=0
    
    for bit in range(2**n):
        check=[0]*m
        for i in range(n):
            if (bit>>i)&1:
                for k in range(m):
                    if i+1 in cnct[k]:
                        check[k]+=1
        
        flg=True
        for k in range(m):
            if check[k]%2!=ps[k]:
                flg=False
        
        if flg:
            ans+=1
    
    print(ans)


if __name__=='__main__':
    do()