# coding: utf-8
# Your code here!
N,M=map(int,input().split())
l=[]*M

for i in range(M):
    l.append(list(map(int,input().split())))
    l[i].pop(0)
    
p=list(map(int,input().split()))

count=0
s=[-1]*10

for i in range(2):
    s[0]=i
    for ii in range(2):
        s[1]=ii
        for iii in range(2):
            s[2]=iii
            for iiii in range(2):
                s[3]=iiii
                for iiiii in range(2):
                    s[4]=iiiii
                    for iiiiii in range(2):
                        s[5]=iiiiii
                        for iiiiiii in range(2):
                            s[6]=iiiiiii
                            for iiiiiiii in range(2):
                                s[7]=iiiiiiii
                                for iiiiiiiii in range(2):
                                    s[8]=iiiiiiiii
                                    for iiiiiiiiii in range(2):
                                        s[9]=iiiiiiiiii
                                        #いかれてる
                                        for j in range(M):
                                            sum=0
                                            is_success=True
                                            for item in l[j]:
                                                sum=sum^s[item]
                                            if sum!=p[j]:
                                                is_success=False
                                                break
                                        if is_success:
                                            count+=1
                                            
print(count/2**(10-N))

### FIXED CODE ###

# coding: utf-8
# Your code here!
N,M=map(int,input().split())
l=[]*M

for i in range(M):
    l.append(list(map(int,input().split())))
    l[i].pop(0)
    
p=list(map(int,input().split()))

count=0
s=[-1]*10

for i in range(2):
    s[0]=i
    for ii in range(2):
        s[1]=ii
        for iii in range(2):
            s[2]=iii
            for iiii in range(2):
                s[3]=iiii
                for iiiii in range(2):
                    s[4]=iiiii
                    for iiiiii in range(2):
                        s[5]=iiiiii
                        for iiiiiii in range(2):
                            s[6]=iiiiiii
                            for iiiiiiii in range(2):
                                s[7]=iiiiiiii
                                for iiiiiiiii in range(2):
                                    s[8]=iiiiiiiii
                                    for iiiiiiiiii in range(2):
                                        s[9]=iiiiiiiiii
                                        #いかれてる
                                        for j in range(M):
                                            sum=0
                                            is_success=True
                                            for item in l[j]:
                                                sum=sum^s[item-1]
                                            if sum!=p[j]:
                                                is_success=False
                                                break
                                        if is_success:
                                            count+=1
                                            
print(int(count/2**(10-N)))