import copy
import math
import time
import statistics
import math

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():
    start = time.time()

    n, m = get_int_multi()

    s = []

    for i in range(m):
        wk = get_int_list()
        wk = wk[1:]
        s.append(wk)

    p = get_int_list()

    ans = 0
    for i in range(2 ** n):
        ok = True
        for ii in range(m): # 電球ごとに調査
            count = 0
            for iii in range(n): # スイッチONOFF
                if ((i >> iii) & 1):
                    if (iii+1) in s[ii]:
                        count += 1
            if (count % 2 != p[ii]):
                ok = False
                break
        if ok:
            ans += 1

    print(ans)



if __name__ == '__main__':
    main()

 import copy copy import math math import time time import statistics statistics import math math def get_int():
    return int(input())
# a = get_string() get_int return int(input()) int(input()) int input() input def get_string():
    return input()
# a_list = get_int_list() get_string return input() input() input def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list(): get_int_list int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x return [int(x) for x in input().split()] [int(x) for x in input().split()] def get_string_list():
    return input().split()
# a, b = get_int_multi() get_string_list return input().split() input().split() ().split () input split def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list() get_int_multi return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a get_string_char_list return list(str(input())) list(str(input())) list str(input()) str input() input '''
while (idx < n) and ():

    idx += 1
''' def main():
    start = time.time()

    n, m = get_int_multi()

    s = []

    for i in range(m):
        wk = get_int_list()
        wk = wk[1:]
        s.append(wk)

    p = get_int_list()

    ans = 0
    for i in range(2 ** n):
        ok = True
        for ii in range(m): # 電球ごとに調査
            count = 0
            for iii in range(n): # スイッチONOFF
                if ((i >> iii) & 1):
                    if (iii+1) in s[ii]:
                        count += 1
            if (count % 2 != p[ii]):
                ok = False
                break
        if ok:
            ans += 1

    print(ans) main start = time.time() start time.time() time.time time time n, m = get_int_multi() n get_int_multi() get_int_multi m s = [] s [] for i in range(m):
        wk = get_int_list()
        wk = wk[1:]
        s.append(wk)

     i range(m) range m wk = get_int_list() wk get_int_list() get_int_list wk = wk[1:] wk wk[1:] wk 1: 1 s.append(wk) s.append s append wk p = get_int_list() p get_int_list() get_int_list ans = 0 ans 0 for i in range(2 ** n):
        ok = True
        for ii in range(m): # 電球ごとに調査
            count = 0
            for iii in range(n): # スイッチONOFF
                if ((i >> iii) & 1):
                    if (iii+1) in s[ii]:
                        count += 1
            if (count % 2 != p[ii]):
                ok = False
                break
        if ok:
            ans += 1

     i range(2 ** n) range 2 ** n 2 n ok = True ok True for ii in range(m): # 電球ごとに調査
            count = 0
            for iii in range(n): # スイッチONOFF
                if ((i >> iii) & 1):
                    if (iii+1) in s[ii]:
                        count += 1
            if (count % 2 != p[ii]):
                ok = False
                break
         ii range(m) range m count = 0 count 0 for iii in range(n): # スイッチONOFF
                if ((i >> iii) & 1):
                    if (iii+1) in s[ii]:
                        count += 1
             iii range(n) range n if ((i >> iii) & 1):
                    if (iii+1) in s[ii]:
                        count += 1
             (i >> iii) & 1 i >> iii i iii 1 if (iii+1) in s[ii]:
                        count += 1
             (iii+1) in s[ii] iii+1 iii 1 s[ii] s ii count += 1 count 1 if (count % 2 != p[ii]):
                ok = False
                break
         count % 2 != p[ii] count % 2 count 2 p[ii] p ii ok = False ok False break if ok:
            ans += 1

     ok ans += 1 ans 1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def get_string():
    return input()
# a_list = get_int_list() def get_string():
    return input()
# a_list = get_int_list() get_string def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list(): def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list(): get_int_list def get_int():
    return int(input())
# a = get_string() def get_int():
    return int(input())
# a = get_string() get_int def main():
    start = time.time()

    n, m = get_int_multi()

    s = []

    for i in range(m):
        wk = get_int_list()
        wk = wk[1:]
        s.append(wk)

    p = get_int_list()

    ans = 0
    for i in range(2 ** n):
        ok = True
        for ii in range(m): # 電球ごとに調査
            count = 0
            for iii in range(n): # スイッチONOFF
                if ((i >> iii) & 1):
                    if (iii+1) in s[ii]:
                        count += 1
            if (count % 2 != p[ii]):
                ok = False
                break
        if ok:
            ans += 1

    print(ans) def main():
    start = time.time()

    n, m = get_int_multi()

    s = []

    for i in range(m):
        wk = get_int_list()
        wk = wk[1:]
        s.append(wk)

    p = get_int_list()

    ans = 0
    for i in range(2 ** n):
        ok = True
        for ii in range(m): # 電球ごとに調査
            count = 0
            for iii in range(n): # スイッチONOFF
                if ((i >> iii) & 1):
                    if (iii+1) in s[ii]:
                        count += 1
            if (count % 2 != p[ii]):
                ok = False
                break
        if ok:
            ans += 1

    print(ans) main def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a get_string_char_list def get_string_list():
    return input().split()
# a, b = get_int_multi() def get_string_list():
    return input().split()
# a, b = get_int_multi() get_string_list def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list() def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list() get_int_multi
import copy
import math
import time
import statistics
import math

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():
    start = time.time()

    n, m = get_int_multi()

    s = []

    for i in range(m):
        wk = get_int_list()
        wk = wk[1:]
        s.append(wk)

    p = get_int_list()

    ans = 0
    for i in range(2 ** n):
        ok = True
        for ii in range(m): # 電球ごとに調査
            count = 0
            for iii in range(n): # スイッチONOFF
                if ((i >> iii) & 1):
                    if (iii+1) in s[ii]:
                        count += 1
            if (count % 2 != p[ii]):
                ok = False
                break
        if ok:
            ans += 1

    print(ans)



if __name__ == '__main__':
    main()


