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

swich = [0] * n

for i in range(m):
    _, *s = map(int, input().split())
    for j in range(len(s)):
        # swich[s[j] - 1] += 1 << (i)
        swich[s[j] - 1] ^= 1 << (i)
        # swich[s[j] - 1] |= 1 << (i)
    


p_list = list(map(int, input().split()))
p = 0
for i in range(m):
    if p_list[i] == 1: 
        p += 1 << i
    # p |= p_list[i] << i #上の処理と同じ

# print("++++++++++++++++++++++++")
# print(swich)
ans = 0
for i in range(1 << n):
    state_on_off = 0
    for index in range(n):
        if i >> index & 1 == 1:
            state_on_off ^= swich[index]
    if state_on_off == p:
        ans += 1
    # print(p, state_on_off,bin(i))
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m swich = [0] * n swich [0] * n [0] 0 n for i in range(m):
    _, *s = map(int, input().split())
    for j in range(len(s)):
        # swich[s[j] - 1] += 1 << (i)
        swich[s[j] - 1] ^= 1 << (i)
        # swich[s[j] - 1] |= 1 << (i)
     i range(m) range m _, *s = map(int, input().split()) _ map(int, input().split()) map int input().split() ().split () input split *s s for j in range(len(s)):
        # swich[s[j] - 1] += 1 << (i)
        swich[s[j] - 1] ^= 1 << (i)
        # swich[s[j] - 1] |= 1 << (i)
     j range(len(s)) range len(s) len s swich[s[j] - 1] ^= 1 << (i) swich[s[j] - 1] swich s[j] - 1 s[j] s j 1 1 << (i) 1 i p_list = list(map(int, input().split())) p_list list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split p = 0 p 0 for i in range(m):
    if p_list[i] == 1: 
        p += 1 << i
    # p |= p_list[i] << i #上の処理と同じ

# print("++++++++++++++++++++++++")
# print(swich) i range(m) range m if p_list[i] == 1: 
        p += 1 << i
    # p |= p_list[i] << i #上の処理と同じ

# print("++++++++++++++++++++++++")
# print(swich) p_list[i] == 1 p_list[i] p_list i 1 p += 1 << i p 1 << i 1 i ans = 0 ans 0 for i in range(1 << n):
    state_on_off = 0
    for index in range(n):
        if i >> index & 1 == 1:
            state_on_off ^= swich[index]
    if state_on_off == p:
        ans += 1
    # print(p, state_on_off,bin(i)) i range(1 << n) range 1 << n 1 n state_on_off = 0 state_on_off 0 for index in range(n):
        if i >> index & 1 == 1:
            state_on_off ^= swich[index]
     index range(n) range n if i >> index & 1 == 1:
            state_on_off ^= swich[index]
     i >> index & 1 == 1 i >> index & 1 i >> index i index 1 1 state_on_off ^= swich[index] state_on_off swich[index] swich index if state_on_off == p:
        ans += 1
    # print(p, state_on_off,bin(i)) state_on_off == p state_on_off p ans += 1 ans 1 print(ans) print ans m = map(int, input().split()) map(int, input().split()) m ans += 1 1 ans p_list = list(map(int, input().split())) list(map(int, input().split())) p_list swich = [0] * n [0] * n swich _, *s = map(int, input().split()) map(int, input().split()) _ p = 0 0 p state_on_off = 0 0 state_on_off p += 1 << i 1 << i p n, m = map(int, input().split()) map(int, input().split()) n state_on_off ^= swich[index] swich[index] state_on_off ans = 0 0 ans
n, m = map(int, input().split())

swich = [0] * n

for i in range(m):
    _, *s = map(int, input().split())
    for j in range(len(s)):
        # swich[s[j] - 1] += 1 << (i)
        swich[s[j] - 1] ^= 1 << (i)
        # swich[s[j] - 1] |= 1 << (i)
    


p_list = list(map(int, input().split()))
p = 0
for i in range(m):
    if p_list[i] == 1: 
        p += 1 << i
    # p |= p_list[i] << i #上の処理と同じ

# print("++++++++++++++++++++++++")
# print(swich)
ans = 0
for i in range(1 << n):
    state_on_off = 0
    for index in range(n):
        if i >> index & 1 == 1:
            state_on_off ^= swich[index]
    if state_on_off == p:
        ans += 1
    # print(p, state_on_off,bin(i))
print(ans)