

# import numpy as np

# import numpypy as np

import sys

input = sys.stdin.readline



def eprint(*args, **kwargs):

    print(*args, file=sys.stderr, **kwargs)



# import math

# import string

# import fractions

# from fractions import Fraction

# from fractions import gcd

# def lcm(n,m):

#     return int(n*m/gcd(n,m))



# import re

# import array

# import copy

# import functools

# import operator



# import collections

# import itertools

# import bisect

# import heapq





# from heapq import heappush

# from heapq import heappop

# from heapq import heappushpop

# from heapq import heapify

# from heapq import heapreplace



# from queue import PriorityQueue as pq



# # from itertools import accumulate

# # from collections import deque

# import random





def main():

    n,m = list(map(int, input().split())) # n represents switch, m represents lights

    lights=[]

    for i in range(m):

        ll=list(map(int, input().split()))

        lights.append(ll[1:])

    p = list(map(int, input().split()))

    eprint(lights)

    # eprint(s)

    # l=s

    # l[1]=[]

    # eprint(l,s)

    

    # cnt_ans=0

    ans=0

    for case in range((1<<n)):

        eprint(bin(case))

        # cnt_switch_on = 0

        ii=0

        f_flag=0

        for light in lights:

            cnt_on=0

            for i in light:

                if (case>>(i-1))&1:

                    cnt_on+=1

            eprint(cnt_on,p[ii])

            if  cnt_on%2!=p[ii]:

                f_flag=1

            ii+=1

        if f_flag==0:

            ans+=1

    print(ans)



        

    #     for i in range(n):

    #         if (case>>i)&1:

    #             cnt_switch_on +=1

    #             eprint("cnt_switch_on",cnt_switch_on)

    #     f_flag=0

    #     for light in range(m):

    #         if cnt_switch_on % 2 == p[light]:

    #             eprint("剰余",cnt_switch_on % 2,"p",p[light])

    #         else:

    #             f_flag=1

    #     if f_flag==0:

    #         cnt_ans+=1

    #     eprint("cnt_ans",cnt_ans)

    

    # print(cnt_ans)





    

    

if __name__ == '__main__':

    main()



# import numpy as np

# import numpypy as np

import sys

input = sys.stdin.readline



def eprint(*args, **kwargs):

    print(*args, file=sys.stderr, **kwargs)



def main():

    n,m = list(map(int, input().split())) # n represents switch, m represents lights

    lights=[]

    for i in range(m):

        ll=list(map(int, input().split()))

        lights.append(ll[1:])

    p = list(map(int, input().split()))

    # eprint(lights)

    # eprint(s)

    ans=0

    for case in range((1<<n)):

        # eprint(bin(case))

        # cnt_switch_on = 0

        ii=0

        f_flag=0

        for light in lights:

            cnt_on=0

            for i in light:

                if (case>>(i-1))&1:

                    cnt_on+=1

            # eprint(cnt_on,p[ii])

            if  cnt_on%2!=p[ii]:

                f_flag=1

            ii+=1

        if f_flag==0:

            ans+=1

    print(ans)

if __name__ == '__main__':

    main()

# import numpy as np
# import numpypy as np
import sys

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd
# def lcm(n,m):
#     return int(n*m/gcd(n,m))
# import re
# import array
# import copy
# import functools
# import operator
# import collections
# import itertools
# import bisect
# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
# # from itertools import accumulate
# # from collections import deque
# import random
def main():
    n, m = list(map(int, input().split()))  # n represents switch, m represents lights
    lights = []
    for i in range(m):
        ll = list(map(int, input().split()))
        lights.append(ll[1:])
    p = list(map(int, input().split()))
    eprint(lights)
    # eprint(s)
    # l=s
    # l[1]=[]
    # eprint(l,s)
    # cnt_ans=0
    ans = 0
    for case in range((1 << n)):
        eprint(bin(case))
        # cnt_switch_on = 0
        ii = 0
        f_flag = 0
        for light in lights:
            cnt_on = 0
            for i in light:
                if (case >> (i - 1)) & 1:
                    cnt_on += 1
            eprint(cnt_on, p[ii])
            if cnt_on % 2 != p[ii]:
                f_flag = 1
            ii += 1
        if f_flag == 0:
            ans += 1
    print(ans)
    #     for i in range(n):
    #         if (case>>i)&1:
    #             cnt_switch_on +=1
    #             eprint("cnt_switch_on",cnt_switch_on)
    #     f_flag=0
    #     for light in range(m):
    #         if cnt_switch_on % 2 == p[light]:
    #             eprint("剰余",cnt_switch_on % 2,"p",p[light])
    #         else:
    #             f_flag=1
    #     if f_flag==0:
    #         cnt_ans+=1
    #     eprint("cnt_ans",cnt_ans)
    # print(cnt_ans)


if __name__ == "__main__":
    main()

# import numpy as np
# import numpypy as np
import sys

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


def main():
    n, m = list(map(int, input().split()))  # n represents switch, m represents lights
    lights = []
    for i in range(m):
        ll = list(map(int, input().split()))
        lights.append(ll[1:])
    p = list(map(int, input().split()))
    # eprint(lights)
    # eprint(s)
    ans = 0
    for case in range((1 << n)):
        # eprint(bin(case))
        # cnt_switch_on = 0
        ii = 0
        f_flag = 0
        for light in lights:
            cnt_on = 0
            for i in light:
                if (case >> (i - 1)) & 1:
                    cnt_on += 1
            # eprint(cnt_on,p[ii])
            if cnt_on % 2 != p[ii]:
                f_flag = 1
            ii += 1
        if f_flag == 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-# import math -# import string -# import fractions -# from fractions import Fraction -# from fractions import gcd -# def lcm(n,m): -#     return int(n*m/gcd(n,m)) -# import re -# import array -# import copy -# import functools -# import operator -# import collections -# import itertools -# import bisect -# import heapq -# from heapq import heappush -# from heapq import heappop -# from heapq import heappushpop -# from heapq import heapify -# from heapq import heapreplace -# from queue import PriorityQueue as pq -# # from itertools import accumulate -# # from collections import deque -# import random -    eprint(lights) +    # eprint(lights) -    # l=s -    # l[1]=[] -    # eprint(l,s) -    # cnt_ans=0 -        eprint(bin(case)) +        # eprint(bin(case)) -            eprint(cnt_on, p[ii]) +            # eprint(cnt_on,p[ii]) -    #     for i in range(n): -    #         if (case>>i)&1: -    #             cnt_switch_on +=1 -    #             eprint("cnt_switch_on",cnt_switch_on) -    #     f_flag=0 -    #     for light in range(m): -    #         if cnt_switch_on % 2 == p[light]: -    #             eprint("剰余",cnt_switch_on % 2,"p",p[light]) -    #         else: -    #             f_flag=1 -    #     if f_flag==0: -    #         cnt_ans+=1 -    #     eprint("cnt_ans",cnt_ans) -    # print(cnt_ans)