N,M = map(int,input().split())
S =[0]*M
for i in range(M):
    k,*s = map(int,input().split())
    S[i] = s

P = list(map(int,input().split()))
ans = 0
for num in range(1<<N):
    Light = [0] * N
    count = 0
    for i in range(N):
        bit = num>>i & 1
        if bit:
            Light[i] = 1
    for i,s in enumerate(S):
        light_count = 0
        p = P[i]
        for si in s:
            if Light[si-1]:
                light_count += 1
        if light_count % 2 == p:
            count+=1
    if count == M:
        ans += 1

print(ans)











 N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M S =[0]*M S [0]*M [0] 0 M for i in range(M):
    k,*s = map(int,input().split())
    S[i] = s i range(M) range M k,*s = map(int,input().split()) k map(int,input().split()) map int input().split() ().split () input split *s s S[i] = s S[i] S i s 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 num in range(1<<N):
    Light = [0] * N
    count = 0
    for i in range(N):
        bit = num>>i & 1
        if bit:
            Light[i] = 1
    for i,s in enumerate(S):
        light_count = 0
        p = P[i]
        for si in s:
            if Light[si-1]:
                light_count += 1
        if light_count % 2 == p:
            count+=1
    if count == M:
        ans += 1 num range(1<<N) range 1<<N 1 N Light = [0] * N Light [0] * N [0] 0 N count = 0 count 0 for i in range(N):
        bit = num>>i & 1
        if bit:
            Light[i] = 1
     i range(N) range N bit = num>>i & 1 bit num>>i & 1 num>>i num i 1 if bit:
            Light[i] = 1
     bit Light[i] = 1 Light[i] Light i 1 for i,s in enumerate(S):
        light_count = 0
        p = P[i]
        for si in s:
            if Light[si-1]:
                light_count += 1
        if light_count % 2 == p:
            count+=1
     i s enumerate(S) enumerate S light_count = 0 light_count 0 p = P[i] p P[i] P i for si in s:
            if Light[si-1]:
                light_count += 1
         si s if Light[si-1]:
                light_count += 1
         Light[si-1] Light si-1 si 1 light_count += 1 light_count 1 if light_count % 2 == p:
            count+=1
     light_count % 2 == p light_count % 2 light_count 2 p count+=1 count 1 if count == M:
        ans += 1 count == M count M ans += 1 ans 1 print(ans) print ans count+=1 1 count S =[0]*M [0]*M S Light = [0] * N [0] * N Light p = P[i] P[i] p P = list(map(int,input().split())) list(map(int,input().split())) P light_count = 0 0 light_count bit = num>>i & 1 num>>i & 1 bit k,*s = map(int,input().split()) map(int,input().split()) k M = map(int,input().split()) map(int,input().split()) M N,M = map(int,input().split()) map(int,input().split()) N light_count += 1 1 light_count ans = 0 0 ans count = 0 0 count ans += 1 1 ans
N,M = map(int,input().split())
S =[0]*M
for i in range(M):
    k,*s = map(int,input().split())
    S[i] = s

P = list(map(int,input().split()))
ans = 0
for num in range(1<<N):
    Light = [0] * N
    count = 0
    for i in range(N):
        bit = num>>i & 1
        if bit:
            Light[i] = 1
    for i,s in enumerate(S):
        light_count = 0
        p = P[i]
        for si in s:
            if Light[si-1]:
                light_count += 1
        if light_count % 2 == p:
            count+=1
    if count == M:
        ans += 1

print(ans)












