#!/usr/bin/env python3



MOD = 2  # type: int





# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    # Failed to predict input format

    N,M = list(map(int,input().split()))

    from collections import defaultdict

    d = defaultdict()

    for i in range(M):

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

        d[i] = l[1:]



    # for k,v in d.items():

    #     print(k,v)



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



    ans = 0

    import itertools

    s = ('on', 'off')

    for i in itertools.product(s, repeat=N):

        anst = 0

        for k,v in list(d.items()):

            if(len([x for x in v if(i[x-1] == 'on')])%2 == p[k]):

                anst += 1



        if(anst == M):

            ans += 1

    

    print(ans)







if __name__ == '__main__':

    main()

#!/usr/bin/env python3



MOD = 2  # type: int







def main():

    N, M = list(map(int, input().split()))

    k = []

    s = []

    for i in range(M):

        l = input().split()

        k.append(l[0])

        s.append(list(map(int, l[1:])))

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



    ans = 0

    

    for i in range(1<<N):

        t = [0] * M

        for j in range(N):

            if i>>j & 1:

                for r in range(M):

                    # print(j+1, s[r])

                    if j+1 in s[r]:

                        t[r] += 1

        f = True

        for j in range(M):

            if t[j]%2 != p[j]:

                f = False

        

        if f:

            ans += 1



    print(ans)

    

    



if __name__ == '__main__':

    main()

#!/usr/bin/env python3
MOD = 2  # type: int
# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    N, M = list(map(int, input().split()))
    from collections import defaultdict

    d = defaultdict()
    for i in range(M):
        l = list(map(int, input().split()))
        d[i] = l[1:]
    # for k,v in d.items():
    #     print(k,v)
    p = list(map(int, input().split()))
    ans = 0
    import itertools

    s = ("on", "off")
    for i in itertools.product(s, repeat=N):
        anst = 0
        for k, v in list(d.items()):
            if len([x for x in v if (i[x - 1] == "on")]) % 2 == p[k]:
                anst += 1
        if anst == M:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
MOD = 2  # type: int


def main():
    N, M = list(map(int, input().split()))
    k = []
    s = []
    for i in range(M):
        l = input().split()
        k.append(l[0])
        s.append(list(map(int, l[1:])))
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1 << N):
        t = [0] * M
        for j in range(N):
            if i >> j & 1:
                for r in range(M):
                    # print(j+1, s[r])
                    if j + 1 in s[r]:
                        t[r] += 1
        f = True
        for j in range(M):
            if t[j] % 2 != p[j]:
                f = False
        if f:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template) + + -    # Failed to predict input format -    from collections import defaultdict - -    d = defaultdict() +    k = [] +    s = [] -        l = list(map(int, input().split())) -        d[i] = l[1:] -    # for k,v in d.items(): -    #     print(k,v) +        l = input().split() +        k.append(l[0]) +        s.append(list(map(int, l[1:]))) -    import itertools - -    s = ("on", "off") -    for i in itertools.product(s, repeat=N): -        anst = 0 -        for k, v in list(d.items()): -            if len([x for x in v if (i[x - 1] == "on")]) % 2 == p[k]: -                anst += 1 -        if anst == M: +    for i in range(1 << N): +        t = [0] * M +        for j in range(N): +            if i >> j & 1: +                for r in range(M): +                    # print(j+1, s[r]) +                    if j + 1 in s[r]: +                        t[r] += 1 +        f = True +        for j in range(M): +            if t[j] % 2 != p[j]: +                f = False +        if f: