def popcount(x):
    x = (x & 0x5555555555555555) + (x >> 1  & 0x5555555555555555)
    x = (x & 0x3333333333333333) + (x >> 2  & 0x3333333333333333)
    x = (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4  & 0x0f0f0f0f0f0f0f0f)
    x = (x & 0x00ff00ff00ff00ff) + (x >> 8  & 0x00ff00ff00ff00ff)
    x = (x & 0x0000ffff0000ffff) + (x >> 16 & 0x0000ffff0000ffff)
    x = (x & 0x00000000ffffffff) + (x >> 32 & 0x00000000ffffffff)
    return x

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

mask = []
for i in range(m):
    vals = list(map(int, input().split()))
    bits = 0
    for s in vals[1:]:
        bits |= 1 << (s-1)
    mask.append(bits)
p = list(map(int, input().split()))

cnt = 0
for i in range(1 << n):
    if all([popcount(i & mask[j]) % 2 ^ p[j] == 0 for j in range(m)]):
        cnt += 1
print(cnt)
    
 def popcount(x):
    x = (x & 0x5555555555555555) + (x >> 1  & 0x5555555555555555)
    x = (x & 0x3333333333333333) + (x >> 2  & 0x3333333333333333)
    x = (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4  & 0x0f0f0f0f0f0f0f0f)
    x = (x & 0x00ff00ff00ff00ff) + (x >> 8  & 0x00ff00ff00ff00ff)
    x = (x & 0x0000ffff0000ffff) + (x >> 16 & 0x0000ffff0000ffff)
    x = (x & 0x00000000ffffffff) + (x >> 32 & 0x00000000ffffffff)
    return x popcount x = (x & 0x5555555555555555) + (x >> 1  & 0x5555555555555555) x (x & 0x5555555555555555) + (x >> 1  & 0x5555555555555555) x & 0x5555555555555555 x 0x5555555555555555 x >> 1  & 0x5555555555555555 x >> 1 x 1 0x5555555555555555 x = (x & 0x3333333333333333) + (x >> 2  & 0x3333333333333333) x (x & 0x3333333333333333) + (x >> 2  & 0x3333333333333333) x & 0x3333333333333333 x 0x3333333333333333 x >> 2  & 0x3333333333333333 x >> 2 x 2 0x3333333333333333 x = (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4  & 0x0f0f0f0f0f0f0f0f) x (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4  & 0x0f0f0f0f0f0f0f0f) x & 0x0f0f0f0f0f0f0f0f x 0x0f0f0f0f0f0f0f0f x >> 4  & 0x0f0f0f0f0f0f0f0f x >> 4 x 4 0x0f0f0f0f0f0f0f0f x = (x & 0x00ff00ff00ff00ff) + (x >> 8  & 0x00ff00ff00ff00ff) x (x & 0x00ff00ff00ff00ff) + (x >> 8  & 0x00ff00ff00ff00ff) x & 0x00ff00ff00ff00ff x 0x00ff00ff00ff00ff x >> 8  & 0x00ff00ff00ff00ff x >> 8 x 8 0x00ff00ff00ff00ff x = (x & 0x0000ffff0000ffff) + (x >> 16 & 0x0000ffff0000ffff) x (x & 0x0000ffff0000ffff) + (x >> 16 & 0x0000ffff0000ffff) x & 0x0000ffff0000ffff x 0x0000ffff0000ffff x >> 16 & 0x0000ffff0000ffff x >> 16 x 16 0x0000ffff0000ffff x = (x & 0x00000000ffffffff) + (x >> 32 & 0x00000000ffffffff) x (x & 0x00000000ffffffff) + (x >> 32 & 0x00000000ffffffff) x & 0x00000000ffffffff x 0x00000000ffffffff x >> 32 & 0x00000000ffffffff x >> 32 x 32 0x00000000ffffffff return x x x x n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m mask = [] mask [] for i in range(m):
    vals = list(map(int, input().split()))
    bits = 0
    for s in vals[1:]:
        bits |= 1 << (s-1)
    mask.append(bits) i range(m) range m vals = list(map(int, input().split())) vals list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bits = 0 bits 0 for s in vals[1:]:
        bits |= 1 << (s-1)
     s vals[1:] vals 1: 1 bits |= 1 << (s-1) bits 1 << (s-1) 1 s-1 s 1 mask.append(bits) mask.append mask append bits 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 = 0 cnt 0 for i in range(1 << n):
    if all([popcount(i & mask[j]) % 2 ^ p[j] == 0 for j in range(m)]):
        cnt += 1 i range(1 << n) range 1 << n 1 n if all([popcount(i & mask[j]) % 2 ^ p[j] == 0 for j in range(m)]):
        cnt += 1 all([popcount(i & mask[j]) % 2 ^ p[j] == 0 for j in range(m)]) all [popcount(i & mask[j]) % 2 ^ p[j] == 0 for j in range(m)] cnt += 1 cnt 1 print(cnt) print cnt def popcount(x):
    x = (x & 0x5555555555555555) + (x >> 1  & 0x5555555555555555)
    x = (x & 0x3333333333333333) + (x >> 2  & 0x3333333333333333)
    x = (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4  & 0x0f0f0f0f0f0f0f0f)
    x = (x & 0x00ff00ff00ff00ff) + (x >> 8  & 0x00ff00ff00ff00ff)
    x = (x & 0x0000ffff0000ffff) + (x >> 16 & 0x0000ffff0000ffff)
    x = (x & 0x00000000ffffffff) + (x >> 32 & 0x00000000ffffffff)
    return x def popcount(x):
    x = (x & 0x5555555555555555) + (x >> 1  & 0x5555555555555555)
    x = (x & 0x3333333333333333) + (x >> 2  & 0x3333333333333333)
    x = (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4  & 0x0f0f0f0f0f0f0f0f)
    x = (x & 0x00ff00ff00ff00ff) + (x >> 8  & 0x00ff00ff00ff00ff)
    x = (x & 0x0000ffff0000ffff) + (x >> 16 & 0x0000ffff0000ffff)
    x = (x & 0x00000000ffffffff) + (x >> 32 & 0x00000000ffffffff)
    return x popcount p = list(map(int, input().split())) list(map(int, input().split())) p n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m mask = [] [] mask bits = 0 0 bits cnt += 1 1 cnt vals = list(map(int, input().split())) list(map(int, input().split())) vals cnt = 0 0 cnt bits |= 1 << (s-1) 1 << (s-1) bits
def popcount(x):
    x = (x & 0x5555555555555555) + (x >> 1  & 0x5555555555555555)
    x = (x & 0x3333333333333333) + (x >> 2  & 0x3333333333333333)
    x = (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4  & 0x0f0f0f0f0f0f0f0f)
    x = (x & 0x00ff00ff00ff00ff) + (x >> 8  & 0x00ff00ff00ff00ff)
    x = (x & 0x0000ffff0000ffff) + (x >> 16 & 0x0000ffff0000ffff)
    x = (x & 0x00000000ffffffff) + (x >> 32 & 0x00000000ffffffff)
    return x

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

mask = []
for i in range(m):
    vals = list(map(int, input().split()))
    bits = 0
    for s in vals[1:]:
        bits |= 1 << (s-1)
    mask.append(bits)
p = list(map(int, input().split()))

cnt = 0
for i in range(1 << n):
    if all([popcount(i & mask[j]) % 2 ^ p[j] == 0 for j in range(m)]):
        cnt += 1
print(cnt)
    

