def solve(Switch, K, P):
    count = 0
    for l_1 in K:
        total = 0
        for i_1 in l_1:
            total += Switch[i_1-1]
        if total % 2 != P[count]:
            return False
        count += 1
    return True

n,m = map(int,input().split())
k = []
for _ in range(m):
    s = list(map(int,input().split()))
    k.append(s[1::])
p = list(map(int,input().split()))

ans = 0

for i in range(2**n):
    switch = [0]*n
    for j in range(n):
        if ((i >> j) &1):
            switch[j] = 1
    if solve(switch, k, p):
        ans+=1

print(ans) def solve(Switch, K, P):
    count = 0
    for l_1 in K:
        total = 0
        for i_1 in l_1:
            total += Switch[i_1-1]
        if total % 2 != P[count]:
            return False
        count += 1
    return True solve count = 0 count 0 for l_1 in K:
        total = 0
        for i_1 in l_1:
            total += Switch[i_1-1]
        if total % 2 != P[count]:
            return False
        count += 1
     l_1 K total = 0 total 0 for i_1 in l_1:
            total += Switch[i_1-1]
         i_1 l_1 total += Switch[i_1-1] total Switch[i_1-1] Switch i_1-1 i_1 1 if total % 2 != P[count]:
            return False
         total % 2 != P[count] total % 2 total 2 P[count] P count return False False count += 1 count 1 return True True Switch Switch K K P P n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m k = [] k [] for _ in range(m):
    s = list(map(int,input().split()))
    k.append(s[1::]) _ range(m) range m s = list(map(int,input().split())) s list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k.append(s[1::]) k.append k append s[1::] s 1:: 1 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 i in range(2**n):
    switch = [0]*n
    for j in range(n):
        if ((i >> j) &1):
            switch[j] = 1
    if solve(switch, k, p):
        ans+=1 i range(2**n) range 2**n 2 n switch = [0]*n switch [0]*n [0] 0 n for j in range(n):
        if ((i >> j) &1):
            switch[j] = 1
     j range(n) range n if ((i >> j) &1):
            switch[j] = 1
     (i >> j) &1 i >> j i j 1 switch[j] = 1 switch[j] switch j 1 if solve(switch, k, p):
        ans+=1 solve(switch, k, p) solve switch k p ans+=1 ans 1 print(ans) print ans n,m = map(int,input().split()) map(int,input().split()) n k = [] [] k ans = 0 0 ans ans+=1 1 ans m = map(int,input().split()) map(int,input().split()) m p = list(map(int,input().split())) list(map(int,input().split())) p switch = [0]*n [0]*n switch s = list(map(int,input().split())) list(map(int,input().split())) s def solve(Switch, K, P):
    count = 0
    for l_1 in K:
        total = 0
        for i_1 in l_1:
            total += Switch[i_1-1]
        if total % 2 != P[count]:
            return False
        count += 1
    return True def solve(Switch, K, P):
    count = 0
    for l_1 in K:
        total = 0
        for i_1 in l_1:
            total += Switch[i_1-1]
        if total % 2 != P[count]:
            return False
        count += 1
    return True solve
def solve(Switch, K, P):
    count = 0
    for l_1 in K:
        total = 0
        for i_1 in l_1:
            total += Switch[i_1-1]
        if total % 2 != P[count]:
            return False
        count += 1
    return True

n,m = map(int,input().split())
k = []
for _ in range(m):
    s = list(map(int,input().split()))
    k.append(s[1::])
p = list(map(int,input().split()))

ans = 0

for i in range(2**n):
    switch = [0]*n
    for j in range(n):
        if ((i >> j) &1):
            switch[j] = 1
    if solve(switch, k, p):
        ans+=1

print(ans)