#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, M = [ int(x) for x in input().split() ]
KS = []
for _i in range(M):
    KS.append([ int(x) for x in input().split() ])
P = [ int(x) for x in input().split() ]

all = [[0,],[1,]]

def add_right(list):
    list0 = [ l + [0,] for l in list ]
    list1 = [ l + [1,] for l in list ]
    list0.extend(list1)
    return list0

for _i in range(N-1):
    all = add_right(all)

ans = 0
d_ans = []
for state in all:
    l_num = -1
    for ks in KS:
        l_num += 1
        switches = ks[1:]
        on = 0
        for s in switches:
            if state[s-1] == 1:
                on += 1
        if on % 2 != P[l_num]:
            break
    else:
        ans += 1

print(ans)
