# 2019-11-13 21:06:16(JST)

import sys

# import collections

# import math

# from string import ascii_lowercase, ascii_uppercase, digits

# from bisect import bisect_left as bi_l, bisect_right as bi_r

import itertools

# from functools import reduce

# import operator as op

# from scipy.misc import comb # float

# import numpy as np 



def main():

    n, m = [int(x) for x in sys.stdin.readline().split()]

    

    on_off_patterns = [''.join(pattern) for pattern in itertools.product('01', repeat=n)]

    

    bulbs = [[int(x) for x in sys.stdin.readline()[1:].split()] for _ in range(m)]

    p = [int(x) for x in sys.stdin.readline().split()]



    combinations = 0

    for i in range(2**n):

        pattern = on_off_patterns[i]

        for j in range(m):

            switches = bulbs[j]

            on_count = 0

            for switch in switches:

                if pattern[switch-1] == '1':

                    on_count += 1

            if on_count % 2 == p[j]:

                continue

            else:

                break

        else:

            combinations += 1

    

    print(combinations)

    

    # enumerate on/off-patters by using binary number.





if __name__ == "__main__":

    main()

import sys



n, m = list(map(int, sys.stdin.readline().split()))

s = [set(map(int, sys.stdin.readline().split()[1:])) for _ in range(m)]

*p, = list(map(int, sys.stdin.readline().split()))



def main():

    combs = 0

    for i in range(2 ** n):

        t = set([j + 1 for j in range(n) if i >> j & 1])

        for k in range(m):

            if len(s[k] & t) & 1 != p[k]:

                break

        else:

            combs += 1

    

    return combs



if __name__ == '__main__':

    ans = main()

    print(ans)
# 2019-11-13 21:06:16(JST)
import sys

# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools

# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np
def main():
    n, m = [int(x) for x in sys.stdin.readline().split()]
    on_off_patterns = [
        "".join(pattern) for pattern in itertools.product("01", repeat=n)
    ]
    bulbs = [[int(x) for x in sys.stdin.readline()[1:].split()] for _ in range(m)]
    p = [int(x) for x in sys.stdin.readline().split()]
    combinations = 0
    for i in range(2**n):
        pattern = on_off_patterns[i]
        for j in range(m):
            switches = bulbs[j]
            on_count = 0
            for switch in switches:
                if pattern[switch - 1] == "1":
                    on_count += 1
            if on_count % 2 == p[j]:
                continue
            else:
                break
        else:
            combinations += 1
    print(combinations)
    # enumerate on/off-patters by using binary number.


if __name__ == "__main__":
    main()

import sys

n, m = list(map(int, sys.stdin.readline().split()))
s = [set(map(int, sys.stdin.readline().split()[1:])) for _ in range(m)]
(*p,) = list(map(int, sys.stdin.readline().split()))


def main():
    combs = 0
    for i in range(2**n):
        t = set([j + 1 for j in range(n) if i >> j & 1])
        for k in range(m):
            if len(s[k] & t) & 1 != p[k]:
                break
        else:
            combs += 1
    return combs


if __name__ == "__main__":
    ans = main()
    print(ans)

-# 2019-11-13 21:06:16(JST) -# import collections -# import math -# from string import ascii_lowercase, ascii_uppercase, digits -# from bisect import bisect_left as bi_l, bisect_right as bi_r -import itertools +n, m = list(map(int, sys.stdin.readline().split())) +s = [set(map(int, sys.stdin.readline().split()[1:])) for _ in range(m)] +(*p,) = list(map(int, sys.stdin.readline().split())) -# from functools import reduce -# import operator as op -# from scipy.misc import comb # float -# import numpy as np + -    n, m = [int(x) for x in sys.stdin.readline().split()] -    on_off_patterns = [ -        "".join(pattern) for pattern in itertools.product("01", repeat=n) -    ] -    bulbs = [[int(x) for x in sys.stdin.readline()[1:].split()] for _ in range(m)] -    p = [int(x) for x in sys.stdin.readline().split()] -    combinations = 0 +    combs = 0 -        pattern = on_off_patterns[i] -        for j in range(m): -            switches = bulbs[j] -            on_count = 0 -            for switch in switches: -                if pattern[switch - 1] == "1": -                    on_count += 1 -            if on_count % 2 == p[j]: -                continue -            else: +        t = set([j + 1 for j in range(n) if i >> j & 1]) +        for k in range(m): +            if len(s[k] & t) & 1 != p[k]: -            combinations += 1 -    print(combinations) -    # enumerate on/off-patters by using binary number. +            combs += 1 +    return combs -    main() +    ans = main() +    print(ans)