def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    tube_to_s = [[int(item) for item in input().split()] for _ in range(M)]
    mods = [int(item) for item in input().split()]

    to_list = [[] for _ in range(M)]

    for i in range(M):
        k, *arg = tube_to_s[i]
        to_list[i] += arg
    
    res = 0
    for i in range(2**N):
        temp_s = format(i, '0{}b'.format(N))
        for j in range(M):
            temp_on_num = 0
            for item in to_list[j]:
                temp_on_num += int(temp_s[item-1])
            
            if temp_on_num % 2 == mods[j]:
                pass
            else:
                break
        else:
            res += 1

    print(res)


if __name__ == "__main__":
    resolve() def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    tube_to_s = [[int(item) for item in input().split()] for _ in range(M)]
    mods = [int(item) for item in input().split()]

    to_list = [[] for _ in range(M)]

    for i in range(M):
        k, *arg = tube_to_s[i]
        to_list[i] += arg
    
    res = 0
    for i in range(2**N):
        temp_s = format(i, '0{}b'.format(N))
        for j in range(M):
            temp_on_num = 0
            for item in to_list[j]:
                temp_on_num += int(temp_s[item-1])
            
            if temp_on_num % 2 == mods[j]:
                pass
            else:
                break
        else:
            res += 1

    print(res) resolve '''
    code here
    ''' int(item) for item in input().split() for item in input().split() item input().split() ().split () input split for item in input().split() int(item) int item N, M = [int(item) for item in input().split()] N [int(item) for item in input().split()] M [int(item) for item in input().split()] for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [int(item) for item in input().split()] tube_to_s = [[int(item) for item in input().split()] for _ in range(M)] tube_to_s [[int(item) for item in input().split()] for _ in range(M)] int(item) for item in input().split() for item in input().split() item input().split() ().split () input split for item in input().split() int(item) int item mods = [int(item) for item in input().split()] mods [int(item) for item in input().split()] [] for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [] to_list = [[] for _ in range(M)] to_list [[] for _ in range(M)] for i in range(M):
        k, *arg = tube_to_s[i]
        to_list[i] += arg
    
     i range(M) range M k, *arg = tube_to_s[i] k tube_to_s[i] tube_to_s i *arg arg to_list[i] += arg to_list[i] to_list i arg res = 0 res 0 for i in range(2**N):
        temp_s = format(i, '0{}b'.format(N))
        for j in range(M):
            temp_on_num = 0
            for item in to_list[j]:
                temp_on_num += int(temp_s[item-1])
            
            if temp_on_num % 2 == mods[j]:
                pass
            else:
                break
        else:
            res += 1

     i range(2**N) range 2**N 2 N temp_s = format(i, '0{}b'.format(N)) temp_s format(i, '0{}b'.format(N)) format i '0{}b'.format(N) '0{}b'.format '0{}b' format N for j in range(M):
            temp_on_num = 0
            for item in to_list[j]:
                temp_on_num += int(temp_s[item-1])
            
            if temp_on_num % 2 == mods[j]:
                pass
            else:
                break
        else:
            res += 1

     j range(M) range M temp_on_num = 0 temp_on_num 0 for item in to_list[j]:
                temp_on_num += int(temp_s[item-1])
            
             item to_list[j] to_list j temp_on_num += int(temp_s[item-1]) temp_on_num int(temp_s[item-1]) int temp_s[item-1] temp_s item-1 item 1 if temp_on_num % 2 == mods[j]:
                pass
            else:
                break
         temp_on_num % 2 == mods[j] temp_on_num % 2 temp_on_num 2 mods[j] mods j break res += 1 res 1 print(res) print res if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    tube_to_s = [[int(item) for item in input().split()] for _ in range(M)]
    mods = [int(item) for item in input().split()]

    to_list = [[] for _ in range(M)]

    for i in range(M):
        k, *arg = tube_to_s[i]
        to_list[i] += arg
    
    res = 0
    for i in range(2**N):
        temp_s = format(i, '0{}b'.format(N))
        for j in range(M):
            temp_on_num = 0
            for item in to_list[j]:
                temp_on_num += int(temp_s[item-1])
            
            if temp_on_num % 2 == mods[j]:
                pass
            else:
                break
        else:
            res += 1

    print(res) def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    tube_to_s = [[int(item) for item in input().split()] for _ in range(M)]
    mods = [int(item) for item in input().split()]

    to_list = [[] for _ in range(M)]

    for i in range(M):
        k, *arg = tube_to_s[i]
        to_list[i] += arg
    
    res = 0
    for i in range(2**N):
        temp_s = format(i, '0{}b'.format(N))
        for j in range(M):
            temp_on_num = 0
            for item in to_list[j]:
                temp_on_num += int(temp_s[item-1])
            
            if temp_on_num % 2 == mods[j]:
                pass
            else:
                break
        else:
            res += 1

    print(res) resolve
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    tube_to_s = [[int(item) for item in input().split()] for _ in range(M)]
    mods = [int(item) for item in input().split()]

    to_list = [[] for _ in range(M)]

    for i in range(M):
        k, *arg = tube_to_s[i]
        to_list[i] += arg
    
    res = 0
    for i in range(2**N):
        temp_s = format(i, '0{}b'.format(N))
        for j in range(M):
            temp_on_num = 0
            for item in to_list[j]:
                temp_on_num += int(temp_s[item-1])
            
            if temp_on_num % 2 == mods[j]:
                pass
            else:
                break
        else:
            res += 1

    print(res)


if __name__ == "__main__":
    resolve()
