import sys
import numpy as np
import itertools
from itertools import product
# from decimal import Decimal
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
k = [list(map(int, readline().split())) for _ in range(m)]
p = list(map(int, readline().split()))

ans = 0
flag = True

for i in product((0, 1), repeat=n):
    #print(i, i[0])

    for j, valK in enumerate(k):
        pp = p[j]
        temp = 0
        for k1, k2 in enumerate(valK):
            if (k1 == 0):
                continue
            else:
                temp += i[k2 - 1]

        if (temp % 2 == pp):
            continue
        else:
            flag = False
            break
    if (flag is False):
        flag = True
        continue
    else:
        ans += 1


print(ans) import sys sys import numpy as np numpy import itertools itertools from itertools import product read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines n, m = map(int, readline().split()) n map(int, readline().split()) map int readline().split() ().split () readline split m list(map(int, readline().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split k = [list(map(int, readline().split())) for _ in range(m)] k [list(map(int, readline().split())) for _ in range(m)] p = list(map(int, readline().split())) p list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split ans = 0 ans 0 flag = True flag True for i in product((0, 1), repeat=n):
    #print(i, i[0])

    for j, valK in enumerate(k):
        pp = p[j]
        temp = 0
        for k1, k2 in enumerate(valK):
            if (k1 == 0):
                continue
            else:
                temp += i[k2 - 1]

        if (temp % 2 == pp):
            continue
        else:
            flag = False
            break
    if (flag is False):
        flag = True
        continue
    else:
        ans += 1 i product((0, 1), repeat=n) product (0, 1) 0 1 repeat=n repeat n for j, valK in enumerate(k):
        pp = p[j]
        temp = 0
        for k1, k2 in enumerate(valK):
            if (k1 == 0):
                continue
            else:
                temp += i[k2 - 1]

        if (temp % 2 == pp):
            continue
        else:
            flag = False
            break
     j valK enumerate(k) enumerate k pp = p[j] pp p[j] p j temp = 0 temp 0 for k1, k2 in enumerate(valK):
            if (k1 == 0):
                continue
            else:
                temp += i[k2 - 1]

         k1 k2 enumerate(valK) enumerate valK if (k1 == 0):
                continue
            else:
                temp += i[k2 - 1]

         k1 == 0 k1 0 continue temp += i[k2 - 1] temp i[k2 - 1] i k2 - 1 k2 1 if (temp % 2 == pp):
            continue
        else:
            flag = False
            break
     temp % 2 == pp temp % 2 temp 2 pp continue flag = False flag False break if (flag is False):
        flag = True
        continue
    else:
        ans += 1 flag is False flag False flag = True flag True continue ans += 1 ans 1 print(ans) print ans n, m = map(int, readline().split()) map(int, readline().split()) n ans = 0 0 ans p = list(map(int, readline().split())) list(map(int, readline().split())) p read = sys.stdin.buffer.read sys.stdin.buffer.read read temp += i[k2 - 1] i[k2 - 1] temp flag = True True flag readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline m = map(int, readline().split()) map(int, readline().split()) m k = [list(map(int, readline().split())) for _ in range(m)] [list(map(int, readline().split())) for _ in range(m)] k flag = True True flag ans += 1 1 ans pp = p[j] p[j] pp flag = False False flag readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines temp = 0 0 temp
import sys
import numpy as np
import itertools
from itertools import product
# from decimal import Decimal
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
k = [list(map(int, readline().split())) for _ in range(m)]
p = list(map(int, readline().split()))

ans = 0
flag = True

for i in product((0, 1), repeat=n):
    #print(i, i[0])

    for j, valK in enumerate(k):
        pp = p[j]
        temp = 0
        for k1, k2 in enumerate(valK):
            if (k1 == 0):
                continue
            else:
                temp += i[k2 - 1]

        if (temp % 2 == pp):
            continue
        else:
            flag = False
            break
    if (flag is False):
        flag = True
        continue
    else:
        ans += 1


print(ans)
