# N = int(input())

# A = [int(x) for x in input().split()]

# V = [[0] * 100 for _ in range(100)]



N, M = [int(x) for x in input().split()]



S = [[0] * N for _ in range(M)]

for m in range(M):

    s = [int(x) for x in input().split()]

    for s1 in s[1:]:

        S[m][s1 - 1] = 1



P = [int(x) for x in input().split()]



cnt = 0

for i in range(2 ** N):

    tmp = True

    for j in range(M):

        c = 0

        for k in range(N):

            if i & (1 << k):

                c += S[j][k]



        if c % 2 != P[j]:

            tmp = False



        # bit = format(i, "08b")

        # print("i(bit):{}, j:{}, c:{},c%2:{}, P[j]:{}".format(bit, j, c, c % 2, P[j]))

    # print("---")



    if tmp == True:

        cnt += 1



print(cnt)

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



S = []

for _ in range(M):

    tmp = [int(x) for x in input().split()]

    k = tmp[0]

    S.append(tmp[1:])

P = [int(x) for x in input().split()]



ret = 0

for pt in range(1<<N):

    allOn = True

    for i in range(M):

        swcnt = 0

        for s in S[i]:

            if pt & (1 << (s-1)):

                swcnt += 1

        if swcnt % 2 != P[i]:

            allOn = False

    if allOn:

        ret += 1



print(ret)





    
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
N, M = [int(x) for x in input().split()]
S = [[0] * N for _ in range(M)]
for m in range(M):
    s = [int(x) for x in input().split()]
    for s1 in s[1:]:
        S[m][s1 - 1] = 1
P = [int(x) for x in input().split()]
cnt = 0
for i in range(2**N):
    tmp = True
    for j in range(M):
        c = 0
        for k in range(N):
            if i & (1 << k):
                c += S[j][k]
        if c % 2 != P[j]:
            tmp = False
        # bit = format(i, "08b")
        # print("i(bit):{}, j:{}, c:{},c%2:{}, P[j]:{}".format(bit, j, c, c % 2, P[j]))
    # print("---")
    if tmp == True:
        cnt += 1
print(cnt)

N, M = list(map(int, input().split()))
S = []
for _ in range(M):
    tmp = [int(x) for x in input().split()]
    k = tmp[0]
    S.append(tmp[1:])
P = [int(x) for x in input().split()]
ret = 0
for pt in range(1 << N):
    allOn = True
    for i in range(M):
        swcnt = 0
        for s in S[i]:
            if pt & (1 << (s - 1)):
                swcnt += 1
        if swcnt % 2 != P[i]:
            allOn = False
    if allOn:
        ret += 1
print(ret)

-# N = int(input()) -# A = [int(x) for x in input().split()] -# V = [[0] * 100 for _ in range(100)] -N, M = [int(x) for x in input().split()] -S = [[0] * N for _ in range(M)] -for m in range(M): -    s = [int(x) for x in input().split()] -    for s1 in s[1:]: -        S[m][s1 - 1] = 1 +N, M = list(map(int, input().split())) +S = [] +for _ in range(M): +    tmp = [int(x) for x in input().split()] +    k = tmp[0] +    S.append(tmp[1:]) -cnt = 0 -for i in range(2**N): -    tmp = True -    for j in range(M): -        c = 0 -        for k in range(N): -            if i & (1 << k): -                c += S[j][k] -        if c % 2 != P[j]: -            tmp = False -        # bit = format(i, "08b") -        # print("i(bit):{}, j:{}, c:{},c%2:{}, P[j]:{}".format(bit, j, c, c % 2, P[j])) -    if tmp == True: -        cnt += 1 -print(cnt) +ret = 0 +for pt in range(1 << N): +    allOn = True +    for i in range(M): +        swcnt = 0 +        for s in S[i]: +            if pt & (1 << (s - 1)): +                swcnt += 1 +        if swcnt % 2 != P[i]: +            allOn = False +    if allOn: +        ret += 1 +print(ret)