import sys
from collections import OrderedDict
input = sys.stdin.buffer.readline

n, m = [int(i) for i in input().split()]
links = OrderedDict()
ans = 0

for i in range(m):
    line = [int(i) for i in input().split()]
    links[i] = line[1:]

conditions = [int(i) for i in input().split()]

switchs = [0] * (n + 1)  # 0:off,1:on
states = [0] * m

for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1:
            switchs[j] = 0
        else:
            switchs[j] = 1
    for i in range(m):
        link = links[i]
        _tmp = 0
        for x in link:
            _tmp += switchs[x - 1]
        if conditions[i] == _tmp % 2:
            states[i] = 1
        else:
            states[i] = 0
    if sum(states) == m:
        ans += 1

print(ans) import sys sys from collections import OrderedDict input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i n, m = [int(i) for i in input().split()] n [int(i) for i in input().split()] m links = OrderedDict() links OrderedDict() OrderedDict ans = 0 ans 0 for i in range(m):
    line = [int(i) for i in input().split()]
    links[i] = line[1:] i range(m) range m int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i line = [int(i) for i in input().split()] line [int(i) for i in input().split()] links[i] = line[1:] links[i] links i line[1:] line 1: 1 int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i conditions = [int(i) for i in input().split()] conditions [int(i) for i in input().split()] switchs = [0] * (n + 1) switchs [0] * (n + 1) [0] 0 n + 1 n 1 states = [0] * m states [0] * m [0] 0 m for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1:
            switchs[j] = 0
        else:
            switchs[j] = 1
    for i in range(m):
        link = links[i]
        _tmp = 0
        for x in link:
            _tmp += switchs[x - 1]
        if conditions[i] == _tmp % 2:
            states[i] = 1
        else:
            states[i] = 0
    if sum(states) == m:
        ans += 1 i range(2**n) range 2**n 2 n for j in range(n):
        if (i >> j) & 1:
            switchs[j] = 0
        else:
            switchs[j] = 1
     j range(n) range n if (i >> j) & 1:
            switchs[j] = 0
        else:
            switchs[j] = 1
     (i >> j) & 1 i >> j i j 1 switchs[j] = 0 switchs[j] switchs j 0 switchs[j] = 1 switchs[j] switchs j 1 for i in range(m):
        link = links[i]
        _tmp = 0
        for x in link:
            _tmp += switchs[x - 1]
        if conditions[i] == _tmp % 2:
            states[i] = 1
        else:
            states[i] = 0
     i range(m) range m link = links[i] link links[i] links i _tmp = 0 _tmp 0 for x in link:
            _tmp += switchs[x - 1]
         x link _tmp += switchs[x - 1] _tmp switchs[x - 1] switchs x - 1 x 1 if conditions[i] == _tmp % 2:
            states[i] = 1
        else:
            states[i] = 0
     conditions[i] == _tmp % 2 conditions[i] conditions i _tmp % 2 _tmp 2 states[i] = 1 states[i] states i 1 states[i] = 0 states[i] states i 0 if sum(states) == m:
        ans += 1 sum(states) == m sum(states) sum states m ans += 1 ans 1 print(ans) print ans ans += 1 1 ans conditions = [int(i) for i in input().split()] [int(i) for i in input().split()] conditions switchs = [0] * (n + 1) [0] * (n + 1) switchs links = OrderedDict() OrderedDict() links link = links[i] links[i] link states = [0] * m [0] * m states line = [int(i) for i in input().split()] [int(i) for i in input().split()] line input = sys.stdin.buffer.readline sys.stdin.buffer.readline input n, m = [int(i) for i in input().split()] [int(i) for i in input().split()] n _tmp = 0 0 _tmp _tmp += switchs[x - 1] switchs[x - 1] _tmp m = [int(i) for i in input().split()] [int(i) for i in input().split()] m ans = 0 0 ans
import sys
from collections import OrderedDict
input = sys.stdin.buffer.readline

n, m = [int(i) for i in input().split()]
links = OrderedDict()
ans = 0

for i in range(m):
    line = [int(i) for i in input().split()]
    links[i] = line[1:]

conditions = [int(i) for i in input().split()]

switchs = [0] * (n + 1)  # 0:off,1:on
states = [0] * m

for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1:
            switchs[j] = 0
        else:
            switchs[j] = 1
    for i in range(m):
        link = links[i]
        _tmp = 0
        for x in link:
            _tmp += switchs[x - 1]
        if conditions[i] == _tmp % 2:
            states[i] = 1
        else:
            states[i] = 0
    if sum(states) == m:
        ans += 1

print(ans)
