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

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

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

answer = 0

## k = sorted(k, reverse=True, key=lambda x: len(x))



all = [] # 全てのスイッチの状態

for i in range(0, 2**n):

  all.append(list(str(format(i, 'b').zfill(n))))



for a in all:

  for index in range(len(k)):

    switch_count = 0 

    for switch in k[index]: #1,2

        switch_count+=int(a[switch-1])

    #一つの電球に繋がってる全てのスイッチ確認終了

    if switch_count%2 == p[index]:

      if index == len(k)-1:

      	answer+=1

      continue

    break



print(answer)

    
#!/usr/bin/env python3



def main():

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

    K = []

    s = []

    answer = 0

    for _ in range(M):

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

        K.append(ks[0])

        s.append(ks[1:])

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



    for switch in range(0,2**N):



        for j in range(M):

            count = 0

            for k in s[j]:

                if 1 << k-1 & switch:

                    count += 1

            if count%2 == p[j]:

                continue

            else:

                break

        else:

            answer +=1



        

    print(answer)





if __name__ == '__main__':

    main()

n, m = list(map(int, input().split()))
k = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
answer = 0
## k = sorted(k, reverse=True, key=lambda x: len(x))
all = []  # 全てのスイッチの状態
for i in range(0, 2**n):
    all.append(list(str(format(i, "b").zfill(n))))
for a in all:
    for index in range(len(k)):
        switch_count = 0
        for switch in k[index]:  # 1,2
            switch_count += int(a[switch - 1])
        # 一つの電球に繋がってる全てのスイッチ確認終了
        if switch_count % 2 == p[index]:
            if index == len(k) - 1:
                answer += 1
            continue
        break
print(answer)

#!/usr/bin/env python3
def main():
    N, M = list(map(int, input().split()))
    K = []
    s = []
    answer = 0
    for _ in range(M):
        ks = list(map(int, input().split()))
        K.append(ks[0])
        s.append(ks[1:])
    p = list(map(int, input().split()))
    for switch in range(0, 2**N):
        for j in range(M):
            count = 0
            for k in s[j]:
                if 1 << k - 1 & switch:
                    count += 1
            if count % 2 == p[j]:
                continue
            else:
                break
        else:
            answer += 1
    print(answer)


if __name__ == "__main__":
    main()

-n, m = list(map(int, input().split())) -k = [list(map(int, input().split()))[1:] for _ in range(m)] -p = list(map(int, input().split())) -answer = 0 -## k = sorted(k, reverse=True, key=lambda x: len(x)) -all = []  # 全てのスイッチの状態 -for i in range(0, 2**n): -    all.append(list(str(format(i, "b").zfill(n)))) -for a in all: -    for index in range(len(k)): -        switch_count = 0 -        for switch in k[index]:  # 1,2 -            switch_count += int(a[switch - 1]) -        # 一つの電球に繋がってる全てのスイッチ確認終了 -        if switch_count % 2 == p[index]: -            if index == len(k) - 1: -                answer += 1 -            continue -        break -print(answer) +#!/usr/bin/env python3 +def main(): +    N, M = list(map(int, input().split())) +    K = [] +    s = [] +    answer = 0 +    for _ in range(M): +        ks = list(map(int, input().split())) +        K.append(ks[0]) +        s.append(ks[1:]) +    p = list(map(int, input().split())) +    for switch in range(0, 2**N): +        for j in range(M): +            count = 0 +            for k in s[j]: +                if 1 << k - 1 & switch: +                    count += 1 +            if count % 2 == p[j]: +                continue +            else: +                break +        else: +            answer += 1 +    print(answer) + + +if __name__ == "__main__": +    main()