n, m = map(int, input().split())
denq = []
for _ in range(m):
    ks = tuple(map(lambda x: int(x)-1, input().split()))
    denq.append(ks[1:])
P = tuple(map(int, input().split()))

ans = 0
for i in range(2**n):
    switch_states = [(i>>j)&1 for j in range(n)]
    for idq, dq in enumerate(denq):
        counts = 0
        for s in dq:
            counts += switch_states[s]
        if counts%2 != P[idq]:
            break
    else:
        ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m denq = [] denq [] for _ in range(m):
    ks = tuple(map(lambda x: int(x)-1, input().split()))
    denq.append(ks[1:]) _ range(m) range m ks = tuple(map(lambda x: int(x)-1, input().split())) ks tuple(map(lambda x: int(x)-1, input().split())) tuple map(lambda x: int(x)-1, input().split()) map lambda x: int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split denq.append(ks[1:]) denq.append denq append ks[1:] ks 1: 1 P = tuple(map(int, input().split())) P tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for i in range(2**n):
    switch_states = [(i>>j)&1 for j in range(n)]
    for idq, dq in enumerate(denq):
        counts = 0
        for s in dq:
            counts += switch_states[s]
        if counts%2 != P[idq]:
            break
    else:
        ans += 1 i range(2**n) range 2**n 2 n (i>>j)&1 for j in range(n) for j in range(n) j range(n) range n for j in range(n) (i>>j)&1 i>>j i j 1 switch_states = [(i>>j)&1 for j in range(n)] switch_states [(i>>j)&1 for j in range(n)] for idq, dq in enumerate(denq):
        counts = 0
        for s in dq:
            counts += switch_states[s]
        if counts%2 != P[idq]:
            break
    else:
        ans += 1 idq dq enumerate(denq) enumerate denq counts = 0 counts 0 for s in dq:
            counts += switch_states[s]
         s dq counts += switch_states[s] counts switch_states[s] switch_states s if counts%2 != P[idq]:
            break
     counts%2 != P[idq] counts%2 counts 2 P[idq] P idq break ans += 1 ans 1 print(ans) print ans counts = 0 0 counts m = map(int, input().split()) map(int, input().split()) m ans = 0 0 ans denq = [] [] denq ans += 1 1 ans P = tuple(map(int, input().split())) tuple(map(int, input().split())) P switch_states = [(i>>j)&1 for j in range(n)] [(i>>j)&1 for j in range(n)] switch_states n, m = map(int, input().split()) map(int, input().split()) n counts += switch_states[s] switch_states[s] counts ks = tuple(map(lambda x: int(x)-1, input().split())) tuple(map(lambda x: int(x)-1, input().split())) ks
n, m = map(int, input().split())
denq = []
for _ in range(m):
    ks = tuple(map(lambda x: int(x)-1, input().split()))
    denq.append(ks[1:])
P = tuple(map(int, input().split()))

ans = 0
for i in range(2**n):
    switch_states = [(i>>j)&1 for j in range(n)]
    for idq, dq in enumerate(denq):
        counts = 0
        for s in dq:
            counts += switch_states[s]
        if counts%2 != P[idq]:
            break
    else:
        ans += 1
print(ans)
