n = list(map(int, input().split()))
sw = []
for x in range(n[1]):
    sw.append(list(map(int, input().split())))
p = list(map(int, input().split()))
kumi = 0

for a in range(2 **n[0]):
    akari = 0
    kai = []
    for b in range(n[0]):
        if ((a >> b)& 1):
            kai.append(b+1)
    #print(kai)
    for c in range(n[1]):
        hantei = 0
        for d in range(1,sw[c][0]+1):
            if kai.count(sw[c][d]) >= 1:
                hantei +=1
        if p[c] == 0 and hantei %2 ==0:
            akari += 1
        elif p[c] == 1 and hantei %2 !=0:
            akari += 1
    if akari == n[1]:
        kumi += 1

print(kumi) n = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split sw = [] sw [] for x in range(n[1]):
    sw.append(list(map(int, input().split()))) x range(n[1]) range n[1] n 1 sw.append(list(map(int, input().split()))) sw.append sw append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split kumi = 0 kumi 0 for a in range(2 **n[0]):
    akari = 0
    kai = []
    for b in range(n[0]):
        if ((a >> b)& 1):
            kai.append(b+1)
    #print(kai)
    for c in range(n[1]):
        hantei = 0
        for d in range(1,sw[c][0]+1):
            if kai.count(sw[c][d]) >= 1:
                hantei +=1
        if p[c] == 0 and hantei %2 ==0:
            akari += 1
        elif p[c] == 1 and hantei %2 !=0:
            akari += 1
    if akari == n[1]:
        kumi += 1 a range(2 **n[0]) range 2 **n[0] 2 n[0] n 0 akari = 0 akari 0 kai = [] kai [] for b in range(n[0]):
        if ((a >> b)& 1):
            kai.append(b+1)
    #print(kai)
     b range(n[0]) range n[0] n 0 if ((a >> b)& 1):
            kai.append(b+1)
    #print(kai)
     (a >> b)& 1 a >> b a b 1 kai.append(b+1) kai.append kai append b+1 b 1 for c in range(n[1]):
        hantei = 0
        for d in range(1,sw[c][0]+1):
            if kai.count(sw[c][d]) >= 1:
                hantei +=1
        if p[c] == 0 and hantei %2 ==0:
            akari += 1
        elif p[c] == 1 and hantei %2 !=0:
            akari += 1
     c range(n[1]) range n[1] n 1 hantei = 0 hantei 0 for d in range(1,sw[c][0]+1):
            if kai.count(sw[c][d]) >= 1:
                hantei +=1
         d range(1,sw[c][0]+1) range 1 sw[c][0]+1 sw[c][0] [c] sw c 0 1 if kai.count(sw[c][d]) >= 1:
                hantei +=1
         kai.count(sw[c][d]) >= 1 kai.count(sw[c][d]) kai.count kai count sw[c][d] [c] sw c d 1 hantei +=1 hantei 1 if p[c] == 0 and hantei %2 ==0:
            akari += 1
        elif p[c] == 1 and hantei %2 !=0:
            akari += 1
     p[c] == 0 and hantei %2 ==0 p[c] == 0 p[c] p c 0 hantei %2 ==0 hantei %2 hantei 2 0 akari += 1 akari 1 elif p[c] == 1 and hantei %2 !=0:
            akari += 1
     p[c] == 1 and hantei %2 !=0 p[c] == 1 p[c] p c 1 hantei %2 !=0 hantei %2 hantei 2 0 akari += 1 akari 1 if akari == n[1]:
        kumi += 1 akari == n[1] akari n[1] n 1 kumi += 1 kumi 1 print(kumi) print kumi kai = [] [] kai sw = [] [] sw akari += 1 1 akari kumi = 0 0 kumi n = list(map(int, input().split())) list(map(int, input().split())) n akari = 0 0 akari p = list(map(int, input().split())) list(map(int, input().split())) p akari += 1 1 akari hantei = 0 0 hantei hantei +=1 1 hantei kumi += 1 1 kumi
n = list(map(int, input().split()))
sw = []
for x in range(n[1]):
    sw.append(list(map(int, input().split())))
p = list(map(int, input().split()))
kumi = 0

for a in range(2 **n[0]):
    akari = 0
    kai = []
    for b in range(n[0]):
        if ((a >> b)& 1):
            kai.append(b+1)
    #print(kai)
    for c in range(n[1]):
        hantei = 0
        for d in range(1,sw[c][0]+1):
            if kai.count(sw[c][d]) >= 1:
                hantei +=1
        if p[c] == 0 and hantei %2 ==0:
            akari += 1
        elif p[c] == 1 and hantei %2 !=0:
            akari += 1
    if akari == n[1]:
        kumi += 1

print(kumi)