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

switch_list = []

for i in range(m):
    s  = list(map(int, input().split()))
    s.pop(0)
    switch_list.append(s)
p_list = list(map(int, input().split()))
#print(switch_list)
#print(p_list)

ans = 0

for bit in range(1 << n): #100・・0(n+1桁)-1 =　111・・・1(n桁)となりn桁のビット演算をfor文で回す
    cnt = 0
    for j in range(0,m):
        switch_sum = 0
        for i in range(n):
            if (bit >> i) & 1 and i+1 in switch_list[j]:
                switch_sum += 1
        if switch_sum%2 == p_list[j]:
            cnt += 1
            if cnt == m:
                ans += 1

print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m switch_list = [] switch_list [] for i in range(m):
    s  = list(map(int, input().split()))
    s.pop(0)
    switch_list.append(s) i 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 s.pop(0) s.pop s pop 0 switch_list.append(s) switch_list.append switch_list append s 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 ans = 0 ans 0 for bit in range(1 << n): #100・・0(n+1桁)-1 =　111・・・1(n桁)となりn桁のビット演算をfor文で回す
    cnt = 0
    for j in range(0,m):
        switch_sum = 0
        for i in range(n):
            if (bit >> i) & 1 and i+1 in switch_list[j]:
                switch_sum += 1
        if switch_sum%2 == p_list[j]:
            cnt += 1
            if cnt == m:
                ans += 1 bit range(1 << n) range 1 << n 1 n cnt = 0 cnt 0 for j in range(0,m):
        switch_sum = 0
        for i in range(n):
            if (bit >> i) & 1 and i+1 in switch_list[j]:
                switch_sum += 1
        if switch_sum%2 == p_list[j]:
            cnt += 1
            if cnt == m:
                ans += 1 j range(0,m) range 0 m switch_sum = 0 switch_sum 0 for i in range(n):
            if (bit >> i) & 1 and i+1 in switch_list[j]:
                switch_sum += 1
         i range(n) range n if (bit >> i) & 1 and i+1 in switch_list[j]:
                switch_sum += 1
         (bit >> i) & 1 and i+1 in switch_list[j] (bit >> i) & 1 bit >> i bit i 1 i+1 in switch_list[j] i+1 i 1 switch_list[j] switch_list j switch_sum += 1 switch_sum 1 if switch_sum%2 == p_list[j]:
            cnt += 1
            if cnt == m:
                ans += 1 switch_sum%2 == p_list[j] switch_sum%2 switch_sum 2 p_list[j] p_list j cnt += 1 cnt 1 if cnt == m:
                ans += 1 cnt == m cnt m ans += 1 ans 1 print(ans) print ans ans += 1 1 ans s  = list(map(int, input().split())) list(map(int, input().split())) s n, m = map(int, input().split()) map(int, input().split()) n p_list = list(map(int, input().split())) list(map(int, input().split())) p_list cnt = 0 0 cnt switch_list = [] [] switch_list switch_sum = 0 0 switch_sum cnt += 1 1 cnt switch_sum += 1 1 switch_sum m = map(int, input().split()) map(int, input().split()) m ans = 0 0 ans
n, m = map(int, input().split())

switch_list = []

for i in range(m):
    s  = list(map(int, input().split()))
    s.pop(0)
    switch_list.append(s)
p_list = list(map(int, input().split()))
#print(switch_list)
#print(p_list)

ans = 0

for bit in range(1 << n): #100・・0(n+1桁)-1 =　111・・・1(n桁)となりn桁のビット演算をfor文で回す
    cnt = 0
    for j in range(0,m):
        switch_sum = 0
        for i in range(n):
            if (bit >> i) & 1 and i+1 in switch_list[j]:
                switch_sum += 1
        if switch_sum%2 == p_list[j]:
            cnt += 1
            if cnt == m:
                ans += 1

print(ans)