N,M = map(int,input().split())
mat = [[int(i) for i in input().split()] for k in range(M)]
p = [int(i) for i in input().split()]
switch = [0]*N
O = [0]*M
L = [False]*M
ans = 0

for i in range(2 ** (N)):
    switchsub = list(format(i,'b'))
    for j in range(len(switchsub)):
        switch[-j-1] = switchsub[-j-1]
    for j in range(N):
        if(switch[j] == "1"):
            for k in range(M):
                for l in range(1,len(mat[k])):
                    if(mat[k][l] == j+1):
                        O[k] += 1
    for j in range(M):
        if(O[j] % 2 == p[j]):
            L[j] = True
    if(False not in L):
        ans += 1
        switch = [0]*N
        O = [0]*M
        L = [False]*M
    if(False in L):
        switch = [0]*N
        O = [0]*M
        L = [False]*M

print(ans) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M [int(i) for i in input().split()] for k in range(M) for k in range(M) k range(M) range M for k in range(M) [int(i) for i in input().split()] mat = [[int(i) for i in input().split()] for k in range(M)] mat [[int(i) for i in input().split()] for k in range(M)] int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i p = [int(i) for i in input().split()] p [int(i) for i in input().split()] switch = [0]*N switch [0]*N [0] 0 N O = [0]*M O [0]*M [0] 0 M L = [False]*M L [False]*M [False] False M ans = 0 ans 0 for i in range(2 ** (N)):
    switchsub = list(format(i,'b'))
    for j in range(len(switchsub)):
        switch[-j-1] = switchsub[-j-1]
    for j in range(N):
        if(switch[j] == "1"):
            for k in range(M):
                for l in range(1,len(mat[k])):
                    if(mat[k][l] == j+1):
                        O[k] += 1
    for j in range(M):
        if(O[j] % 2 == p[j]):
            L[j] = True
    if(False not in L):
        ans += 1
        switch = [0]*N
        O = [0]*M
        L = [False]*M
    if(False in L):
        switch = [0]*N
        O = [0]*M
        L = [False]*M i range(2 ** (N)) range 2 ** (N) 2 N switchsub = list(format(i,'b')) switchsub list(format(i,'b')) list format(i,'b') format i 'b' for j in range(len(switchsub)):
        switch[-j-1] = switchsub[-j-1]
     j range(len(switchsub)) range len(switchsub) len switchsub switch[-j-1] = switchsub[-j-1] switch[-j-1] switch -j-1 -j j 1 switchsub[-j-1] switchsub -j-1 -j j 1 for j in range(N):
        if(switch[j] == "1"):
            for k in range(M):
                for l in range(1,len(mat[k])):
                    if(mat[k][l] == j+1):
                        O[k] += 1
     j range(N) range N if(switch[j] == "1"):
            for k in range(M):
                for l in range(1,len(mat[k])):
                    if(mat[k][l] == j+1):
                        O[k] += 1
     switch[j] == "1" switch[j] switch j "1" for k in range(M):
                for l in range(1,len(mat[k])):
                    if(mat[k][l] == j+1):
                        O[k] += 1
     k range(M) range M for l in range(1,len(mat[k])):
                    if(mat[k][l] == j+1):
                        O[k] += 1
     l range(1,len(mat[k])) range 1 len(mat[k]) len mat[k] mat k if(mat[k][l] == j+1):
                        O[k] += 1
     mat[k][l] == j+1 mat[k][l] [k] mat k l j+1 j 1 O[k] += 1 O[k] O k 1 for j in range(M):
        if(O[j] % 2 == p[j]):
            L[j] = True
     j range(M) range M if(O[j] % 2 == p[j]):
            L[j] = True
     O[j] % 2 == p[j] O[j] % 2 O[j] O j 2 p[j] p j L[j] = True L[j] L j True if(False not in L):
        ans += 1
        switch = [0]*N
        O = [0]*M
        L = [False]*M
     False not in L False L ans += 1 ans 1 switch = [0]*N switch [0]*N [0] 0 N O = [0]*M O [0]*M [0] 0 M L = [False]*M L [False]*M [False] False M if(False in L):
        switch = [0]*N
        O = [0]*M
        L = [False]*M False in L False L switch = [0]*N switch [0]*N [0] 0 N O = [0]*M O [0]*M [0] 0 M L = [False]*M L [False]*M [False] False M print(ans) print ans ans = 0 0 ans mat = [[int(i) for i in input().split()] for k in range(M)] [[int(i) for i in input().split()] for k in range(M)] mat O = [0]*M [0]*M O M = map(int,input().split()) map(int,input().split()) M L = [False]*M [False]*M L ans += 1 1 ans switch = [0]*N [0]*N switch N,M = map(int,input().split()) map(int,input().split()) N O = [0]*M [0]*M O L = [False]*M [False]*M L O = [0]*M [0]*M O switch = [0]*N [0]*N switch L = [False]*M [False]*M L p = [int(i) for i in input().split()] [int(i) for i in input().split()] p switch = [0]*N [0]*N switch switchsub = list(format(i,'b')) list(format(i,'b')) switchsub
N,M = map(int,input().split())
mat = [[int(i) for i in input().split()] for k in range(M)]
p = [int(i) for i in input().split()]
switch = [0]*N
O = [0]*M
L = [False]*M
ans = 0

for i in range(2 ** (N)):
    switchsub = list(format(i,'b'))
    for j in range(len(switchsub)):
        switch[-j-1] = switchsub[-j-1]
    for j in range(N):
        if(switch[j] == "1"):
            for k in range(M):
                for l in range(1,len(mat[k])):
                    if(mat[k][l] == j+1):
                        O[k] += 1
    for j in range(M):
        if(O[j] % 2 == p[j]):
            L[j] = True
    if(False not in L):
        ans += 1
        switch = [0]*N
        O = [0]*M
        L = [False]*M
    if(False in L):
        switch = [0]*N
        O = [0]*M
        L = [False]*M

print(ans)