#!usr/bin/env python3

from collections import defaultdict

from collections import deque

from heapq import heappush, heappop

import sys

import math

import bisect

import random

def LI(): return list(map(int, sys.stdin.readline().split()))

def I(): return int(sys.stdin.readline())

def LS():return list(map(list, sys.stdin.readline().split()))

def S(): return list(sys.stdin.readline())[:-1]

def IR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = I()

    return l

def LIR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = LI()

    return l

def SR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = S()

    return l

def LSR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = LS()

    return l

sys.setrecursionlimit(1000000)

mod = 1000000007



#A

def A():

    a,p = LI()

    print(((a*3+p)//2))

    return



#B

def B():

    n = I()

    s = [None for i in range(n)]

    for i in range(n):

        l = input().split()

        s[i] = l+[i]

    s.sort(key = lambda x:(x[0],-int(x[1])))

    for i,a,b in s:

        print((b+1))

    return



#C

def C():

    def dfs(d,k):

        if d == n:

            l.append(k)

        else:

            dfs(d+1,k+[0])

            dfs(d+1,k+[1])

    n,m = LI()

    l = []

    dfs(0,[])

    qu = LIR(m)

    p = LI()

    ans = 0

    for k in l:

        s = 0

        for q in range(m):

            num = qu[q][0]

            lis = list([x-1 for x in qu[q][1:]])

            su = 0

            for i in lis:

                su ^= k[i]

            if su == p[q]:

                s += 1

        if s == m:

            ans += 1

    print(ans)

    return



#D

def D():

    n = I()



    return



#E

def E():

    n = I()



    return



#F

def F():

    n = I()



    return



#Solve

if __name__ == "__main__":

    C()

#!usr/bin/env python3

from collections import defaultdict,deque

from heapq import heappush, heappop

import sys

import math

import bisect

import random

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())

def LS():return [list(x) for x in sys.stdin.readline().split()]

def S():

    res = list(sys.stdin.readline())

    if res[-1] == "\n":

        return res[:-1]

    return res

def IR(n):

    return [I() for i in range(n)]

def LIR(n):

    return [LI() for i in range(n)]

def SR(n):

    return [S() for i in range(n)]

def LSR(n):

    return [LS() for i in range(n)]



sys.setrecursionlimit(1000000)

mod = 1000000007



def solve():

    n,m = LI()

    s = LIR(m)

    p = LI()

    ans = 0

    for i in range(m):

        s[i] = sum([1<<(j-1) for j in s[i][1:]])

    for b in range(1<<n):

        for i in range(m):

            if bin(s[i]&b).count("1")&1 != p[i]:

                break

        else:ans += 1

    print(ans)

    return



#Solve

if __name__ == "__main__":

    solve()

#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random


def LI():
    return list(map(int, sys.stdin.readline().split()))


def I():
    return int(sys.stdin.readline())


def LS():
    return list(map(list, sys.stdin.readline().split()))


def S():
    return list(sys.stdin.readline())[:-1]


def IR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = I()
    return l


def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = LI()
    return l


def SR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = S()
    return l


def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = LS()
    return l


sys.setrecursionlimit(1000000)
mod = 1000000007
# A
def A():
    a, p = LI()
    print(((a * 3 + p) // 2))
    return


# B
def B():
    n = I()
    s = [None for i in range(n)]
    for i in range(n):
        l = input().split()
        s[i] = l + [i]
    s.sort(key=lambda x: (x[0], -int(x[1])))
    for i, a, b in s:
        print((b + 1))
    return


# C
def C():
    def dfs(d, k):
        if d == n:
            l.append(k)
        else:
            dfs(d + 1, k + [0])
            dfs(d + 1, k + [1])

    n, m = LI()
    l = []
    dfs(0, [])
    qu = LIR(m)
    p = LI()
    ans = 0
    for k in l:
        s = 0
        for q in range(m):
            num = qu[q][0]
            lis = list([x - 1 for x in qu[q][1:]])
            su = 0
            for i in lis:
                su ^= k[i]
            if su == p[q]:
                s += 1
        if s == m:
            ans += 1
    print(ans)
    return


# D
def D():
    n = I()
    return


# E
def E():
    n = I()
    return


# F
def F():
    n = I()
    return


# Solve
if __name__ == "__main__":
    C()

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def I():
    return int(sys.stdin.readline())


def LS():
    return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, m = LI()
    s = LIR(m)
    p = LI()
    ans = 0
    for i in range(m):
        s[i] = sum([1 << (j - 1) for j in s[i][1:]])
    for b in range(1 << n):
        for i in range(m):
            if bin(s[i] & b).count("1") & 1 != p[i]:
                break
        else:
            ans += 1
    print(ans)
    return


# Solve
if __name__ == "__main__":
    solve()

-from collections import defaultdict -from collections import deque +from collections import defaultdict, deque -    return list(map(int, sys.stdin.readline().split())) +    return [int(x) for x in sys.stdin.readline().split()] -    return list(map(list, sys.stdin.readline().split())) +    return [list(x) for x in sys.stdin.readline().split()] -    return list(sys.stdin.readline())[:-1] +    res = list(sys.stdin.readline()) +    if res[-1] == "\n": +        return res[:-1] +    return res -    l = [None for i in range(n)] -    for i in range(n): -        l[i] = I() -    return l +    return [I() for i in range(n)] -    l = [None for i in range(n)] -    for i in range(n): -        l[i] = LI() -    return l +    return [LI() for i in range(n)] -    l = [None for i in range(n)] -    for i in range(n): -        l[i] = S() -    return l +    return [S() for i in range(n)] -    l = [None for i in range(n)] -    for i in range(n): -        l[i] = LS() -    return l +    return [LS() for i in range(n)] -# A -def A(): -    a, p = LI() -    print(((a * 3 + p) // 2)) -    return -# B -def B(): -    n = I() -    s = [None for i in range(n)] -    for i in range(n): -        l = input().split() -        s[i] = l + [i] -    s.sort(key=lambda x: (x[0], -int(x[1]))) -    for i, a, b in s: -        print((b + 1)) -    return - - -# C -def C(): -    def dfs(d, k): -        if d == n: -            l.append(k) -        else: -            dfs(d + 1, k + [0]) -            dfs(d + 1, k + [1]) - +def solve(): -    l = [] -    dfs(0, []) -    qu = LIR(m) +    s = LIR(m) -    for k in l: -        s = 0 -        for q in range(m): -            num = qu[q][0] -            lis = list([x - 1 for x in qu[q][1:]]) -            su = 0 -            for i in lis: -                su ^= k[i] -            if su == p[q]: -                s += 1 -        if s == m: +    for i in range(m): +        s[i] = sum([1 << (j - 1) for j in s[i][1:]]) +    for b in range(1 << n): +        for i in range(m): +            if bin(s[i] & b).count("1") & 1 != p[i]: +                break +        else: -# D -def D(): -    n = I() -    return - - -# E -def E(): -    n = I() -    return - - -# F -def F(): -    n = I() -    return - - -    C() +    solve()