# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math
# mod = 10**9 + 7

from itertools import product

n, m = map(int, input().split())
s = [list(map(lambda x:int(x)-1,input().split())) for _ in range(m)]
p = list(map(int,input().split()))


count = 0
for i in product([0,1], repeat=n):
    i = list(i)
    on = True
    for j in range(m):
        score = 0
        for k in s[j]:
            if i[k] == 1:
                score += 1
        if score % 2 == p[j]:
            continue

        else:
            on = False
            break

    if on:
        count += 1

print(count)