import numpy as np
from itertools import product

def main():
    n, m = [int(i) for i in input().split()]
    sw = np.zeros((m, n), int)
    for i in range(m):
        for s in input().split()[1:]:
            sw[i][int(s)-1] = 1

    p = np.array([int(i) for i in input().split()])
    print(sw)
    res = 0
    for t in product((0, 1), repeat=n):
        stat = np.array(t)
        if np.array_equal(p, np.dot(sw, stat) % 2):
            res += 1
    print(res)


if __name__ == '__main__':
    main()

