import numpy as np
N, M = map(int, input().split())
bulbs = []
for _ in range(M):
    bulbs.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))

# print('bulbs', bulbs)
# print('P', P)


def f(state):
    for bulb, p in zip(bulbs, P):
        if state[[bulb]].sum() % 2 != p:
            return 0
    return 1


ans = 0
for i in range(N**2):
    state = format(i, 'b').zfill(N)
    state = np.array(list(map(int, ['9'] + list(state))))
    # if f(state) == 1:
    # print(state)
    ans += f(state)

print(ans)
