n, m = map(int,input().split())

k = []
s_l = []
for _ in range(m):
    l = list(map(int, input().split()))
    k.append(l[0])
    s_l.append(l[1:])

p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    valid = 1
    for j in range(m):
        on = 0
        for s in s_l[j]:
            on += (i >> (s-1) & 1)
        if on % 2 == p[j]:
            valid *= 1
        else:
            valid *= 0
    ans += valid

print(ans)


 n, m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m k = [] k [] s_l = [] s_l [] for _ in range(m):
    l = list(map(int, input().split()))
    k.append(l[0])
    s_l.append(l[1:]) _ range(m) range m l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k.append(l[0]) k.append k append l[0] l 0 s_l.append(l[1:]) s_l.append s_l append l[1:] l 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):
    valid = 1
    for j in range(m):
        on = 0
        for s in s_l[j]:
            on += (i >> (s-1) & 1)
        if on % 2 == p[j]:
            valid *= 1
        else:
            valid *= 0
    ans += valid i range(2**n) range 2**n 2 n valid = 1 valid 1 for j in range(m):
        on = 0
        for s in s_l[j]:
            on += (i >> (s-1) & 1)
        if on % 2 == p[j]:
            valid *= 1
        else:
            valid *= 0
     j range(m) range m on = 0 on 0 for s in s_l[j]:
            on += (i >> (s-1) & 1)
         s s_l[j] s_l j on += (i >> (s-1) & 1) on i >> (s-1) & 1 i >> (s-1) i s-1 s 1 1 if on % 2 == p[j]:
            valid *= 1
        else:
            valid *= 0
     on % 2 == p[j] on % 2 on 2 p[j] p j valid *= 1 valid 1 valid *= 0 valid 0 ans += valid ans valid print(ans) print ans l = list(map(int, input().split())) list(map(int, input().split())) l ans = 0 0 ans p = list(map(int,input().split())) list(map(int,input().split())) p on += (i >> (s-1) & 1) i >> (s-1) & 1 on on = 0 0 on valid *= 1 1 valid valid = 1 1 valid k = [] [] k s_l = [] [] s_l ans += valid valid ans m = map(int,input().split()) map(int,input().split()) m valid *= 0 0 valid n, m = map(int,input().split()) map(int,input().split()) n
n, m = map(int,input().split())

k = []
s_l = []
for _ in range(m):
    l = list(map(int, input().split()))
    k.append(l[0])
    s_l.append(l[1:])

p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    valid = 1
    for j in range(m):
        on = 0
        for s in s_l[j]:
            on += (i >> (s-1) & 1)
        if on % 2 == p[j]:
            valid *= 1
        else:
            valid *= 0
    ans += valid

print(ans)



