n,m=map(int,input().split())
ks=[]
for i in range(m):
    temp=list(map(int,input().split()))
    ks.append(temp)
p=list(map(int,input().split()))
cnt_ans=0
for i in range(1<<n):
    cnt_on=0
    for j in range(0,m):
        cnt=0
        for k in range(1,ks[j][0]+1):
            if (i>>(ks[j][k]-1))%2==1:
                cnt+=1
        if cnt%2==p[j]:
            cnt_on+=1
    if cnt_on==m:
        cnt_ans+=1
print(cnt_ans)
 n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ks=[] ks [] for i in range(m):
    temp=list(map(int,input().split()))
    ks.append(temp) i range(m) range m temp=list(map(int,input().split())) temp list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ks.append(temp) ks.append ks append temp p=list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split cnt_ans=0 cnt_ans 0 for i in range(1<<n):
    cnt_on=0
    for j in range(0,m):
        cnt=0
        for k in range(1,ks[j][0]+1):
            if (i>>(ks[j][k]-1))%2==1:
                cnt+=1
        if cnt%2==p[j]:
            cnt_on+=1
    if cnt_on==m:
        cnt_ans+=1 i range(1<<n) range 1<<n 1 n cnt_on=0 cnt_on 0 for j in range(0,m):
        cnt=0
        for k in range(1,ks[j][0]+1):
            if (i>>(ks[j][k]-1))%2==1:
                cnt+=1
        if cnt%2==p[j]:
            cnt_on+=1
     j range(0,m) range 0 m cnt=0 cnt 0 for k in range(1,ks[j][0]+1):
            if (i>>(ks[j][k]-1))%2==1:
                cnt+=1
         k range(1,ks[j][0]+1) range 1 ks[j][0]+1 ks[j][0] [j] ks j 0 1 if (i>>(ks[j][k]-1))%2==1:
                cnt+=1
         (i>>(ks[j][k]-1))%2==1 (i>>(ks[j][k]-1))%2 i>>(ks[j][k]-1) i ks[j][k]-1 ks[j][k] [j] ks j k 1 2 1 cnt+=1 cnt 1 if cnt%2==p[j]:
            cnt_on+=1
     cnt%2==p[j] cnt%2 cnt 2 p[j] p j cnt_on+=1 cnt_on 1 if cnt_on==m:
        cnt_ans+=1 cnt_on==m cnt_on m cnt_ans+=1 cnt_ans 1 print(cnt_ans) print cnt_ans n,m=map(int,input().split()) map(int,input().split()) n cnt_ans+=1 1 cnt_ans cnt_on=0 0 cnt_on cnt_on+=1 1 cnt_on m=map(int,input().split()) map(int,input().split()) m ks=[] [] ks temp=list(map(int,input().split())) list(map(int,input().split())) temp cnt+=1 1 cnt cnt_ans=0 0 cnt_ans p=list(map(int,input().split())) list(map(int,input().split())) p cnt=0 0 cnt
n,m=map(int,input().split())
ks=[]
for i in range(m):
    temp=list(map(int,input().split()))
    ks.append(temp)
p=list(map(int,input().split()))
cnt_ans=0
for i in range(1<<n):
    cnt_on=0
    for j in range(0,m):
        cnt=0
        for k in range(1,ks[j][0]+1):
            if (i>>(ks[j][k]-1))%2==1:
                cnt+=1
        if cnt%2==p[j]:
            cnt_on+=1
    if cnt_on==m:
        cnt_ans+=1
print(cnt_ans)

