#!/usr/bin/env python

import sys

n,m = [ int(x) for x in sys.stdin.readline().split() ]
s = list()
for _ in range(m):
    t= [ int(x) for x in sys.stdin.readline().split() ][1:]
    flag = 0
    for x in t: flag|= x
    s.append( flag )
p = [ int(x) for x in sys.stdin.readline().split() ]
#
ans= 0
for test in range(2**n):
    fail= False
    for i in range(m):
        if bin(s[i]&test).count("1")%2 != p[i]:
            fail= True
            break
    #
    if not fail: ans+= 1
#
print( ans )
