import sys



stdin = sys.stdin

inf = 1 << 60

mod = 1000000007



ni      = lambda: int(ns())

nin     = lambda y: [ni() for _ in range(y)]

na      = lambda: list(map(int, stdin.readline().split()))

nan     = lambda y: [na() for _ in range(y)]

nf      = lambda: float(ns())

nfn     = lambda y: [nf() for _ in range(y)]

nfa     = lambda: list(map(float, stdin.readline().split()))

nfan    = lambda y: [nfa() for _ in range(y)]

ns      = lambda: stdin.readline().rstrip()

nsn     = lambda y: [ns() for _ in range(y)]

ncl     = lambda y: [list(ns()) for _ in range(y)]

nas     = lambda: stdin.readline().split()



n, m = na()

ks = nan(m)

p = na()



ans = 0

for i in range(2 ** n):

    on = dict()

    for j in range(n):

        if (i >> j) & 1:

            on[j + 1] = True

    l = 0

    for j in range(m):

        k, s = ks[j][0], ks[j][1:]

        sum_on = 0

        for a in range(k):

            if on.get(s[a], False):

                sum_on += 1

        if sum_on % 2 == p[j]:

            l += 1

    if l == m:

        ans += 1



print(ans)
import sys



stdin = sys.stdin

inf = 1 << 60

mod = 1000000007



ni      = lambda: int(ns())

nin     = lambda y: [ni() for _ in range(y)]

na      = lambda: list(map(int, stdin.readline().split()))

nan     = lambda y: [na() for _ in range(y)]

nf      = lambda: float(ns())

nfn     = lambda y: [nf() for _ in range(y)]

nfa     = lambda: list(map(float, stdin.readline().split()))

nfan    = lambda y: [nfa() for _ in range(y)]

ns      = lambda: stdin.readline().rstrip()

nsn     = lambda y: [ns() for _ in range(y)]

ncl     = lambda y: [list(ns()) for _ in range(y)]

nas     = lambda: stdin.readline().split()



n, m = na()

ks = nan(m)

p = na()



ans = 0

for i in range(2 ** n):

    ok = True

    for j in range(m):

        k, s = ks[j][0], ks[j][1:]

        sum_on = 0

        for a in range(k):

            if (i >> (s[a] - 1)) & 1:

                sum_on += 1

        if sum_on % 2 != p[j]:

            ok = False

    if ok:

        ans += 1



print(ans)
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()
n, m = na()
ks = nan(m)
p = na()
ans = 0
for i in range(2**n):
    on = dict()
    for j in range(n):
        if (i >> j) & 1:
            on[j + 1] = True
    l = 0
    for j in range(m):
        k, s = ks[j][0], ks[j][1:]
        sum_on = 0
        for a in range(k):
            if on.get(s[a], False):
                sum_on += 1
        if sum_on % 2 == p[j]:
            l += 1
    if l == m:
        ans += 1
print(ans)

import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()
n, m = na()
ks = nan(m)
p = na()
ans = 0
for i in range(2**n):
    ok = True
    for j in range(m):
        k, s = ks[j][0], ks[j][1:]
        sum_on = 0
        for a in range(k):
            if (i >> (s[a] - 1)) & 1:
                sum_on += 1
        if sum_on % 2 != p[j]:
            ok = False
    if ok:
        ans += 1
print(ans)

-    on = dict() -    for j in range(n): -        if (i >> j) & 1: -            on[j + 1] = True -    l = 0 +    ok = True -            if on.get(s[a], False): +            if (i >> (s[a] - 1)) & 1: -        if sum_on % 2 == p[j]: -            l += 1 -    if l == m: +        if sum_on % 2 != p[j]: +            ok = False +    if ok: