# cs: c nnected switches
n, m = map(int, input().split())

def get_connected_switches():
    # k s1 s2 .. sn
    lst = list(map(int, input().split()))
    lst.pop(0) # k is not use
    return list(map(lambda d: 1<<(d-1), lst ))

# cs: connected switches
cs = [get_connected_switches() for _ in range(m)]
ps = list(map(int, input().split()))

# bit全探索(0: すべてoffは不要)
ans = 0
# on: 0:消えてる、1:点いてる
# 10: 1 2  3   4 
# 0b: 1 10 11, 100..
for on in range(2**n):
    ok = True
    for i in range(m):
        ct = 0
        for s in cs[i]:
            if s&on: ct += 1
        if ct%2 != ps[i]:
            ok = False
    if ok:
        ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m def get_connected_switches():
    # k s1 s2 .. sn
    lst = list(map(int, input().split()))
    lst.pop(0) # k is not use
    return list(map(lambda d: 1<<(d-1), lst ))

# cs: connected switches get_connected_switches lst = list(map(int, input().split())) lst list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split lst.pop(0) lst.pop lst pop 0 return list(map(lambda d: 1<<(d-1), lst )) list(map(lambda d: 1<<(d-1), lst )) list map(lambda d: 1<<(d-1), lst ) map lambda d: 1<<(d-1) 1<<(d-1) 1 d-1 d 1 d lst get_connected_switches() for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) get_connected_switches() get_connected_switches cs = [get_connected_switches() for _ in range(m)] cs [get_connected_switches() for _ in range(m)] ps = list(map(int, input().split())) ps list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for on in range(2**n):
    ok = True
    for i in range(m):
        ct = 0
        for s in cs[i]:
            if s&on: ct += 1
        if ct%2 != ps[i]:
            ok = False
    if ok:
        ans += 1 on range(2**n) range 2**n 2 n ok = True ok True for i in range(m):
        ct = 0
        for s in cs[i]:
            if s&on: ct += 1
        if ct%2 != ps[i]:
            ok = False
     i range(m) range m ct = 0 ct 0 for s in cs[i]:
            if s&on: ct += 1
         s cs[i] cs i if s&on: ct += 1
         s&on s on if ct%2 != ps[i]:
            ok = False
     ct%2 != ps[i] ct%2 ct 2 ps[i] ps i ok = False ok False if ok:
        ans += 1 ok ans += 1 ans 1 print(ans) print ans ans = 0 0 ans ans += 1 1 ans n, m = map(int, input().split()) map(int, input().split()) n def get_connected_switches():
    # k s1 s2 .. sn
    lst = list(map(int, input().split()))
    lst.pop(0) # k is not use
    return list(map(lambda d: 1<<(d-1), lst ))

# cs: connected switches def get_connected_switches():
    # k s1 s2 .. sn
    lst = list(map(int, input().split()))
    lst.pop(0) # k is not use
    return list(map(lambda d: 1<<(d-1), lst ))

# cs: connected switches get_connected_switches ct = 0 0 ct ps = list(map(int, input().split())) list(map(int, input().split())) ps cs = [get_connected_switches() for _ in range(m)] [get_connected_switches() for _ in range(m)] cs ok = False False ok m = map(int, input().split()) map(int, input().split()) m ok = True True ok
# cs: c nnected switches
n, m = map(int, input().split())

def get_connected_switches():
    # k s1 s2 .. sn
    lst = list(map(int, input().split()))
    lst.pop(0) # k is not use
    return list(map(lambda d: 1<<(d-1), lst ))

# cs: connected switches
cs = [get_connected_switches() for _ in range(m)]
ps = list(map(int, input().split()))

# bit全探索(0: すべてoffは不要)
ans = 0
# on: 0:消えてる、1:点いてる
# 10: 1 2  3   4 
# 0b: 1 10 11, 100..
for on in range(2**n):
    ok = True
    for i in range(m):
        ct = 0
        for s in cs[i]:
            if s&on: ct += 1
        if ct%2 != ps[i]:
            ok = False
    if ok:
        ans += 1
print(ans)
