#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections


N,M = map(int, sys.stdin.readline().rstrip().split(" "))
switches = []
for _ in range(M):
    k, *s = map(int, sys.stdin.readline().rstrip().split(" "))
    # switches.append(s)
    switch_bit = sum(2**v for v in s)
    switches.append(switch_bit)
ps = list(map(int, sys.stdin.readline().rstrip().split(" ")))



result = 0
for i in range(2**N):
    for j,switch in enumerate(switches):
        pattern = switch | i
        if not bin(pattern).count("1") % 2 == ps[j]:
            break
    else:
        result += 1
print(result)


exit(0)