# -*- coding:utf-8 -*-

from itertools import product



def solve():

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

    K, S = [], []

    for _ in range(M):

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

        K.append(_in[0])

        S.append(_in[1:])

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



    all_stats = product((0,1), repeat=N)

    ans = 0

    for stat in all_stats:

        is_ok = True

        for switch_i, switch in enumerate(S):

            on_num = 0

            for i in range(len(switch)):

                if stat[switch[i]-1] == 1:

                    on_num += 1

            if on_num%2 != P[switch_i]:

                is_ok = False

                break

        if is_ok:

            ans += 1

    print(ans)



if __name__ == "__main__":

    solve()

# -*- coding:utf-8 -*-

import itertools



def solve():

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

    Ks, Ss = [], []

    for i in range(M):

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

        Ks.append(_in[0])

        Ss.append(_in[1:])

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



    # 全探索でいける

    switches = itertools.product([0,1], repeat=N)

    ans = 0

    for switch in switches:

        is_ok = True

        for i in range(M):

            on_num = 0

            for s in Ss[i]:

                if switch[s-1] == 1:

                    on_num += 1

            if on_num%2 != Ps[i]:

                is_ok = False

                break

        

        if is_ok:

            ans += 1



    print(ans)

    







if __name__ == "__main__":

    solve()

# -*- coding:utf-8 -*-
from itertools import product


def solve():
    N, M = list(map(int, input().split()))
    K, S = [], []
    for _ in range(M):
        _in = list(map(int, input().split()))
        K.append(_in[0])
        S.append(_in[1:])
    P = list(map(int, input().split()))
    all_stats = product((0, 1), repeat=N)
    ans = 0
    for stat in all_stats:
        is_ok = True
        for switch_i, switch in enumerate(S):
            on_num = 0
            for i in range(len(switch)):
                if stat[switch[i] - 1] == 1:
                    on_num += 1
            if on_num % 2 != P[switch_i]:
                is_ok = False
                break
        if is_ok:
            ans += 1
    print(ans)


if __name__ == "__main__":
    solve()

# -*- coding:utf-8 -*-
import itertools


def solve():
    N, M = list(map(int, input().split()))
    Ks, Ss = [], []
    for i in range(M):
        _in = list(map(int, input().split()))
        Ks.append(_in[0])
        Ss.append(_in[1:])
    Ps = list(map(int, input().split()))
    # 全探索でいける
    switches = itertools.product([0, 1], repeat=N)
    ans = 0
    for switch in switches:
        is_ok = True
        for i in range(M):
            on_num = 0
            for s in Ss[i]:
                if switch[s - 1] == 1:
                    on_num += 1
            if on_num % 2 != Ps[i]:
                is_ok = False
                break
        if is_ok:
            ans += 1
    print(ans)


if __name__ == "__main__":
    solve()

-from itertools import product +import itertools -    K, S = [], [] -    for _ in range(M): +    Ks, Ss = [], [] +    for i in range(M): -        K.append(_in[0]) -        S.append(_in[1:]) -    P = list(map(int, input().split())) -    all_stats = product((0, 1), repeat=N) +        Ks.append(_in[0]) +        Ss.append(_in[1:]) +    Ps = list(map(int, input().split())) +    # 全探索でいける +    switches = itertools.product([0, 1], repeat=N) -    for stat in all_stats: +    for switch in switches: -        for switch_i, switch in enumerate(S): +        for i in range(M): -            for i in range(len(switch)): -                if stat[switch[i] - 1] == 1: +            for s in Ss[i]: +                if switch[s - 1] == 1: -            if on_num % 2 != P[switch_i]: +            if on_num % 2 != Ps[i]: