# -*- coding: utf-8 -*-

"""

Created on Sun May 26 20:56:00 2019



@author: Yamazaki Kenichi

"""



N,M = list(map(int,input().split()))

ks = [list(map(int,input().split())) for i in range(M)]

p = list(map(int,input().split()))



ans = 0

for i in range(2**N):

    t = '{:010b}'.format(i)

    flg = True

    for j in range(M):

        tmp = 0

        for k in range(ks[j][0]):

            tmp += int(t[-ks[j][k+1]])

#        print(i,j,t,tmp,ans)

        if tmp%2 == p[j]:

            continue

        else:

            flg = False

            break

#    print(i,j,t,tmp,ans,flg)

    if flg:

        ans += 1



            

print(ans)
# -*- coding: utf-8 -*-

"""

Created on Mon May 27 21:28:42 2019



@author: Yamazaki Kenichi

"""



N, M = list(map(int,input().split()))

ks = [list(map(int,input().split())) for i in range(M)]

p = list(map(int,input().split()))



S = [0 for i in range(M)]

for i in range(M):

    for j in range(1,ks[i][0]+1):

        S[i] += 2**(ks[i][j]-1)



ans = 0

for i in range(2**N):

    flg = True

    for j in range(M):

        if ('{:010b}'.format(S[j]&i)).count('1') % 2 == p[j]:

            continue

        else:

            flg = False

            break

    if flg:

        ans += 1

print(ans)
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:56:00 2019
@author: Yamazaki Kenichi
"""
N, M = list(map(int, input().split()))
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
    t = "{:010b}".format(i)
    flg = True
    for j in range(M):
        tmp = 0
        for k in range(ks[j][0]):
            tmp += int(t[-ks[j][k + 1]])
        #        print(i,j,t,tmp,ans)
        if tmp % 2 == p[j]:
            continue
        else:
            flg = False
            break
    #    print(i,j,t,tmp,ans,flg)
    if flg:
        ans += 1
print(ans)

# -*- coding: utf-8 -*-
"""
Created on Mon May 27 21:28:42 2019
@author: Yamazaki Kenichi
"""
N, M = list(map(int, input().split()))
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
S = [0 for i in range(M)]
for i in range(M):
    for j in range(1, ks[i][0] + 1):
        S[i] += 2 ** (ks[i][j] - 1)
ans = 0
for i in range(2**N):
    flg = True
    for j in range(M):
        if ("{:010b}".format(S[j] & i)).count("1") % 2 == p[j]:
            continue
        else:
            flg = False
            break
    if flg:
        ans += 1
print(ans)

-Created on Sun May 26 20:56:00 2019 +Created on Mon May 27 21:28:42 2019 +S = [0 for i in range(M)] +for i in range(M): +    for j in range(1, ks[i][0] + 1): +        S[i] += 2 ** (ks[i][j] - 1) -    t = "{:010b}".format(i) -        tmp = 0 -        for k in range(ks[j][0]): -            tmp += int(t[-ks[j][k + 1]]) -        #        print(i,j,t,tmp,ans) -        if tmp % 2 == p[j]: +        if ("{:010b}".format(S[j] & i)).count("1") % 2 == p[j]: -    #    print(i,j,t,tmp,ans,flg)