n, m = map(int, raw_input().split(" "))

switch = []
for i in range(0, m):
    s = map(int, raw_input().split(" "))
    switch.append(s[1:])

power = map(int, raw_input().split(" "))

ans = 0
for state_int in range(0, 2 ** n):
    format_str = "{:0" + str(n) + "b}"
    state_bin = format_str.format(state_int)
    # print(state_bin)

    state = [0 for j in range(0, len(state_bin))]
    for i in range(0, len(state)):
        if state_bin[i] == "1":
            state[i] = True
        else:
            state[i] = False

    # print(state)
    on = True
    for s in range(0, m):
        ts = switch[s]
        count = 0

        for j in range(0, len(ts)):
            if state[ts[j] - 1]:
                count += 1

        if power[s] != count % 2:
            on = False
            break

    if on:
        # print(state_bin)
        ans += 1

print(ans)
