import numpy as np

N, M = map(int, input().split())
lamplist = []
for i in range(M):
    A = list(map(int, input().split()))
    lamplist.append(A)
oddeven_ans = list(map(int, input().split()))

switch = np.zeros(N)
ans = 0
numofswitch = np.zeros(M)

for s in range(M):
    numofswitch[s] = lamplist[s][0]
    del lamplist[s][0]


for j in range(2 ** N):
    ansflag = 0
    oddeven = 0
    for k in range(N):
        switch[k] = j % 2
        j //= 2
    for p in range(M):
        for r in range(int(numofswitch[p])):
            if switch[lamplist[p][r] - 1] == 1:
                oddeven += 1

        if oddeven % 2 != oddeven_ans[p]:
            ansflag = 1
    if ansflag == 0:
        ans += 1

print("{}".format(ans))

