n, m = map(int, input().split())
connection = []
switch_num = []
criterion = []
counter = 0
for i in range(m):
    switchnum_connection = input().split()
    switch_num.append(int(switchnum_connection[0]))
    con = []
    for j in range(switch_num[i]):
        con.append(int(switchnum_connection[j+1]))
    connection.append(con)
#print(connection)
crit = input().split()
for i in crit:
    criterion.append(int(i))
for switch in range(2**n):
    switch_str = format(switch, '0{}b'.format(n))
    state = []
    count = 0
    token = 1
    for bi in switch_str:
        state.append(int(bi))
    for light in range(m):    
        for j in range(switch_num[light]):
            #print(state)
            count += state[connection[light][j]-1]
        if (count + criterion[light]) % 2 == 1:
            token = 0
    if token == 1:
        counter += 1

print(counter)