'''

https://atcoder.jp/contests/abc128/tasks/abc128_c

'''

def main():

    import sys

    #input = sys.stdin.readline

    sys.setrecursionlimit(10000000)

    from collections import Counter, deque



    #mod = 1000000007



    n, m = list(map(int, input().split()))

    switch_list = [list(map(int, input().split())) for _ in range(m)]

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

    ret = 0

    for j in range(2**n):

        cnt = 0

        for i in range(m):

            total = 0

            for k in switch_list[i][1:]:

                if j & 2**(k-1):

                    total += 1

            if total%2 == p[i]:

                cnt += 1

            else:

                break

        if cnt == m:

            ret += 1

    print(ret)

if __name__ == '__main__':

    main()
def main():

    n, m = list(map(int, input().split()))

    switch_list = [list(map(int, input().split())) for _ in range(m)]

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

    ret = 0

    for j in range(2**n):

        for i in range(m):

            total = 0

            flag = 1

            for k in switch_list[i][1:]:

                if j & 2**(k-1):

                    total += 1

            if not total%2 == p[i]:

                flag = 0

                break

        if flag:

            ret += 1

    print(ret)



if __name__ == '__main__':

    main()
"""
https://atcoder.jp/contests/abc128/tasks/abc128_c
"""


def main():
    import sys

    # input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque

    # mod = 1000000007
    n, m = list(map(int, input().split()))
    switch_list = [list(map(int, input().split())) for _ in range(m)]
    p = list(map(int, input().split()))
    ret = 0
    for j in range(2**n):
        cnt = 0
        for i in range(m):
            total = 0
            for k in switch_list[i][1:]:
                if j & 2 ** (k - 1):
                    total += 1
            if total % 2 == p[i]:
                cnt += 1
            else:
                break
        if cnt == m:
            ret += 1
    print(ret)


if __name__ == "__main__":
    main()

def main():
    n, m = list(map(int, input().split()))
    switch_list = [list(map(int, input().split())) for _ in range(m)]
    p = list(map(int, input().split()))
    ret = 0
    for j in range(2**n):
        for i in range(m):
            total = 0
            flag = 1
            for k in switch_list[i][1:]:
                if j & 2 ** (k - 1):
                    total += 1
            if not total % 2 == p[i]:
                flag = 0
                break
        if flag:
            ret += 1
    print(ret)


if __name__ == "__main__":
    main()

-""" -https://atcoder.jp/contests/abc128/tasks/abc128_c -""" - - -    import sys - -    # input = sys.stdin.readline -    sys.setrecursionlimit(10000000) -    from collections import Counter, deque - -    # mod = 1000000007 -        cnt = 0 +            flag = 1 -            if total % 2 == p[i]: -                cnt += 1 -            else: +            if not total % 2 == p[i]: +                flag = 0 -        if cnt == m: +        if flag: