n,m = map( int, input().split() )
ks = []
for i in range(m):
    ks.append( list( map( int, input().split() ) ) )
p = list( map( int, input().split() ) )

ks_nums = [0]*m
for i in range(m):
    for j in range(ks[i][0]):
        ks_nums[i] += 2**(ks[i][j+1]-1)

ans = 0
success = True
for i in range(2**m):
    for j in range(m):
        cnt = 0
        tmp = i & ks_nums[j]
        for k in range(m):
            if ( tmp >> k ) & 1:
                cnt += 1
        if p[j] != cnt % 2:
            success = False
            break
    if success:
        ans += 1
    else:
        success = True

print(ans)