#!/usr/bin/env python

# input
n, m = map(int, input().split())
t = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
k = [t[i][0] for i in range(m)]
s = [t[i][1:] for i in range(m)]

# calc
# bit full search
ans = 0 
for i in range(2**n):
    tmp = i 
    sw = []
    if i == 0:
        sw = [0] 
    while tmp > 0:
        sw.append(tmp&1)
        tmp = tmp>>1
    while len(sw) < n:
        sw.append(0)

    #print('sw =', sw)
    
    # check whether current sw satisfies the condision.
    ok = True
    # light bulb j
    for j in range(m):
        tmp = 0 
        for a in range(k[j]):
            tmp += sw[s[j][a]-1]
        if tmp%2 != p[j]:
            ok = False
            break
    if ok: 
        # print('sw =', sw)
        ans += 1

print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split t = [list(map(int, input().split())) for _ in range(m)] t [list(map(int, input().split())) for _ in range(m)] p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split t[i][0] for i in range(m) for i in range(m) i range(m) range m for i in range(m) t[i][0] [i] t i 0 k = [t[i][0] for i in range(m)] k [t[i][0] for i in range(m)] t[i][1:] for i in range(m) for i in range(m) i range(m) range m for i in range(m) t[i][1:] [i] t i 1: 1 s = [t[i][1:] for i in range(m)] s [t[i][1:] for i in range(m)] ans = 0 ans 0 for i in range(2**n):
    tmp = i 
    sw = []
    if i == 0:
        sw = [0] 
    while tmp > 0:
        sw.append(tmp&1)
        tmp = tmp>>1
    while len(sw) < n:
        sw.append(0)

    #print('sw =', sw)
    
    # check whether current sw satisfies the condision.
    ok = True
    # light bulb j
    for j in range(m):
        tmp = 0 
        for a in range(k[j]):
            tmp += sw[s[j][a]-1]
        if tmp%2 != p[j]:
            ok = False
            break
    if ok: 
        # print('sw =', sw)
        ans += 1 i range(2**n) range 2**n 2 n tmp = i tmp i sw = [] sw [] if i == 0:
        sw = [0] 
     i == 0 i 0 sw = [0] sw [0] 0 while tmp > 0:
        sw.append(tmp&1)
        tmp = tmp>>1
     tmp > 0 tmp 0 sw.append(tmp&1) sw.append sw append tmp&1 tmp 1 tmp = tmp>>1 tmp tmp>>1 tmp 1 while len(sw) < n:
        sw.append(0)

    #print('sw =', sw)
    
    # check whether current sw satisfies the condision.
     len(sw) < n len(sw) len sw n sw.append(0) sw.append sw append 0 ok = True ok True for j in range(m):
        tmp = 0 
        for a in range(k[j]):
            tmp += sw[s[j][a]-1]
        if tmp%2 != p[j]:
            ok = False
            break
     j range(m) range m tmp = 0 tmp 0 for a in range(k[j]):
            tmp += sw[s[j][a]-1]
         a range(k[j]) range k[j] k j tmp += sw[s[j][a]-1] tmp sw[s[j][a]-1] sw s[j][a]-1 s[j][a] [j] s j a 1 if tmp%2 != p[j]:
            ok = False
            break
     tmp%2 != p[j] tmp%2 tmp 2 p[j] p j ok = False ok False break if ok: 
        # print('sw =', sw)
        ans += 1 ok ans += 1 ans 1 print(ans) print ans s = [t[i][1:] for i in range(m)] [t[i][1:] for i in range(m)] s m = map(int, input().split()) map(int, input().split()) m sw = [0] [0] sw n, m = map(int, input().split()) map(int, input().split()) n ans += 1 1 ans t = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] t p = list(map(int, input().split())) list(map(int, input().split())) p tmp = i i tmp ans = 0 0 ans tmp = 0 0 tmp tmp += sw[s[j][a]-1] sw[s[j][a]-1] tmp sw = [] [] sw tmp = tmp>>1 tmp>>1 tmp k = [t[i][0] for i in range(m)] [t[i][0] for i in range(m)] k ok = True True ok ok = False False ok
#!/usr/bin/env python

# input
n, m = map(int, input().split())
t = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
k = [t[i][0] for i in range(m)]
s = [t[i][1:] for i in range(m)]

# calc
# bit full search
ans = 0 
for i in range(2**n):
    tmp = i 
    sw = []
    if i == 0:
        sw = [0] 
    while tmp > 0:
        sw.append(tmp&1)
        tmp = tmp>>1
    while len(sw) < n:
        sw.append(0)

    #print('sw =', sw)
    
    # check whether current sw satisfies the condision.
    ok = True
    # light bulb j
    for j in range(m):
        tmp = 0 
        for a in range(k[j]):
            tmp += sw[s[j][a]-1]
        if tmp%2 != p[j]:
            ok = False
            break
    if ok: 
        # print('sw =', sw)
        ans += 1

print(ans)
