import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7



def LI(): return list(map(int,input().split()))

def I(): return int(eval(input()))

def LS(): return input().split()

def S(): return eval(input())



def main():

  n,m=LI()

  l2=[]

  for _ in range(m):

    l2.append(LI())



  l3=LI()



  l=[]

  a=len(bin(1<<n))-3

  for i in range(1<<n):

    l.append(str(bin(i))[2:].zfill(a))



  cnt=0

  for x in l:

    x=list(x)



    f=True

    for i in range(len(l2)):



      y=l2[i]

      c=0



      for a in y[1:]:

        c+=int(x[a-1])



      # print(c,l3[i])

      if c%2==l3[i]:

        pass

      else:

        f=False

        break



    if f:

      cnt+=1



  return cnt



print((main()))

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7

dd=[(-1,0),(0,1),(1,0),(0,-1)]

ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]



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

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

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

def LS(): return sys.stdin.readline().split()

def S(): return eval(input())



def main():

  n,m=LI()



  l=[]

  for _ in range(m):

    a=LI()

    l.append(a[1:])



  l2=LI()



  pattern=[]

  for i in range(1<<n):

    _l=[]

    for j in range(n):

      _l.append(1 if i&(1<<j) else 0)

    pattern.append(_l)



  ans=0

  for x in pattern:

    f=True

    for i,y in enumerate(l):

      on_num=0

      for z in y:

        on_num+=x[z-1]



      if not f:

        break

      if f and l2[i]!=on_num%2:

        f=False

        break



    if f:

      ans+=1



  return ans



# main()

print((main()))

import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def LI():
    return list(map(int, input().split()))


def I():
    return int(eval(input()))


def LS():
    return input().split()


def S():
    return eval(input())


def main():
    n, m = LI()
    l2 = []
    for _ in range(m):
        l2.append(LI())
    l3 = LI()
    l = []
    a = len(bin(1 << n)) - 3
    for i in range(1 << n):
        l.append(str(bin(i))[2:].zfill(a))
    cnt = 0
    for x in l:
        x = list(x)
        f = True
        for i in range(len(l2)):
            y = l2[i]
            c = 0
            for a in y[1:]:
                c += int(x[a - 1])
            # print(c,l3[i])
            if c % 2 == l3[i]:
                pass
            else:
                f = False
                break
        if f:
            cnt += 1
    return cnt


print((main()))

import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


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


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


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


def LS():
    return sys.stdin.readline().split()


def S():
    return eval(input())


def main():
    n, m = LI()
    l = []
    for _ in range(m):
        a = LI()
        l.append(a[1:])
    l2 = LI()
    pattern = []
    for i in range(1 << n):
        _l = []
        for j in range(n):
            _l.append(1 if i & (1 << j) else 0)
        pattern.append(_l)
    ans = 0
    for x in pattern:
        f = True
        for i, y in enumerate(l):
            on_num = 0
            for z in y:
                on_num += x[z - 1]
            if not f:
                break
            if f and l2[i] != on_num % 2:
                f = False
                break
        if f:
            ans += 1
    return ans


# main()
print((main()))

-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time +import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy +dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] +ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] -    return list(map(int, input().split())) +    return [int(x) for x in sys.stdin.readline().split()] + + +def LI_(): +    return [int(x) - 1 for x in sys.stdin.readline().split()] -    return int(eval(input())) +    return int(sys.stdin.readline()) -    return input().split() +    return sys.stdin.readline().split() -    l2 = [] +    l = [] -        l2.append(LI()) -    l3 = LI() -    l = [] -    a = len(bin(1 << n)) - 3 +        a = LI() +        l.append(a[1:]) +    l2 = LI() +    pattern = [] -        l.append(str(bin(i))[2:].zfill(a)) -    cnt = 0 -    for x in l: -        x = list(x) +        _l = [] +        for j in range(n): +            _l.append(1 if i & (1 << j) else 0) +        pattern.append(_l) +    ans = 0 +    for x in pattern: -        for i in range(len(l2)): -            y = l2[i] -            c = 0 -            for a in y[1:]: -                c += int(x[a - 1]) -            # print(c,l3[i]) -            if c % 2 == l3[i]: -                pass -            else: +        for i, y in enumerate(l): +            on_num = 0 +            for z in y: +                on_num += x[z - 1] +            if not f: +                break +            if f and l2[i] != on_num % 2: -            cnt += 1 -    return cnt +            ans += 1 +    return ans +# main()