# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    n, m = [int(x) for x in input().split()]
    s = []
    for _ in range(m):
        k, *r = [int(x) - 1 for x in input().split()]
        s.append(r)
    p = [int(x) for x in input().split()]
    ans = 0
    for i in range(2 ** n): # mask
        ok = 1
        for j in range(m): # bulb
            pp = p[j]
            cnt = 0
            for ss in s[j]:
                if i & (1 << ss):
                    cnt += 1
            if cnt % 2 != pp:
                ok = 0
        ans += ok
    print(ans)

    


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

""" import sys sys from collections import deque, defaultdict from math import sqrt, factorial, gcd, ceil, atan, pi import string string from bisect import bisect_left MOD = int(1e9)+7 MOD int(1e9)+7 int(1e9) int 1e9 7 INF = float('inf') INF float('inf') float 'inf' def solve():
    # n, m = [int(x) for x in input().split()]
    n, m = [int(x) for x in input().split()]
    s = []
    for _ in range(m):
        k, *r = [int(x) - 1 for x in input().split()]
        s.append(r)
    p = [int(x) for x in input().split()]
    ans = 0
    for i in range(2 ** n): # mask
        ok = 1
        for j in range(m): # bulb
            pp = p[j]
            cnt = 0
            for ss in s[j]:
                if i & (1 << ss):
                    cnt += 1
            if cnt % 2 != pp:
                ok = 0
        ans += ok
    print(ans)

     solve 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 n, m = [int(x) for x in input().split()] n [int(x) for x in input().split()] m s = [] s [] for _ in range(m):
        k, *r = [int(x) - 1 for x in input().split()]
        s.append(r)
     _ range(m) range m int(x) - 1 for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) - 1 int(x) int x 1 k, *r = [int(x) - 1 for x in input().split()] k [int(x) - 1 for x in input().split()] *r r s.append(r) s.append s append r 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 p = [int(x) for x in input().split()] p [int(x) for x in input().split()] ans = 0 ans 0 for i in range(2 ** n): # mask
        ok = 1
        for j in range(m): # bulb
            pp = p[j]
            cnt = 0
            for ss in s[j]:
                if i & (1 << ss):
                    cnt += 1
            if cnt % 2 != pp:
                ok = 0
        ans += ok
     i range(2 ** n) range 2 ** n 2 n ok = 1 ok 1 for j in range(m): # bulb
            pp = p[j]
            cnt = 0
            for ss in s[j]:
                if i & (1 << ss):
                    cnt += 1
            if cnt % 2 != pp:
                ok = 0
         j range(m) range m pp = p[j] pp p[j] p j cnt = 0 cnt 0 for ss in s[j]:
                if i & (1 << ss):
                    cnt += 1
             ss s[j] s j if i & (1 << ss):
                    cnt += 1
             i & (1 << ss) i 1 << ss 1 ss cnt += 1 cnt 1 if cnt % 2 != pp:
                ok = 0
         cnt % 2 != pp cnt % 2 cnt 2 pp ok = 0 ok 0 ans += ok ans ok print(ans) print ans t = 1 t 1 for case in range(1,t+1):
    ans = solve() case range(1,t+1) range 1 t+1 t 1 ans = solve() ans solve() solve """

azyxwvutsrqponmlkjihgfedcb

""" MOD = int(1e9)+7 int(1e9)+7 MOD t = 1 1 t ans = solve() solve() ans INF = float('inf') float('inf') INF def solve():
    # n, m = [int(x) for x in input().split()]
    n, m = [int(x) for x in input().split()]
    s = []
    for _ in range(m):
        k, *r = [int(x) - 1 for x in input().split()]
        s.append(r)
    p = [int(x) for x in input().split()]
    ans = 0
    for i in range(2 ** n): # mask
        ok = 1
        for j in range(m): # bulb
            pp = p[j]
            cnt = 0
            for ss in s[j]:
                if i & (1 << ss):
                    cnt += 1
            if cnt % 2 != pp:
                ok = 0
        ans += ok
    print(ans)

     def solve():
    # n, m = [int(x) for x in input().split()]
    n, m = [int(x) for x in input().split()]
    s = []
    for _ in range(m):
        k, *r = [int(x) - 1 for x in input().split()]
        s.append(r)
    p = [int(x) for x in input().split()]
    ans = 0
    for i in range(2 ** n): # mask
        ok = 1
        for j in range(m): # bulb
            pp = p[j]
            cnt = 0
            for ss in s[j]:
                if i & (1 << ss):
                    cnt += 1
            if cnt % 2 != pp:
                ok = 0
        ans += ok
    print(ans)

     solve
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    n, m = [int(x) for x in input().split()]
    s = []
    for _ in range(m):
        k, *r = [int(x) - 1 for x in input().split()]
        s.append(r)
    p = [int(x) for x in input().split()]
    ans = 0
    for i in range(2 ** n): # mask
        ok = 1
        for j in range(m): # bulb
            pp = p[j]
            cnt = 0
            for ss in s[j]:
                if i & (1 << ss):
                    cnt += 1
            if cnt % 2 != pp:
                ok = 0
        ans += ok
    print(ans)

    


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""
