package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	var N, M int
	fmt.Scanf("%d %d", &N, &M)
	NS := strconv.Itoa(N)
	reader := bufio.NewReader(os.Stdin)
	s := make([][]int, M+1, M+1)
	for i := 1; i <= M; i++ {
		line, _, _ := reader.ReadLine()
		dataS := strings.Split(string(line), " ")
		dataI := make([]int, len(dataS), len(dataS))
		for j := range dataS {
			dataI[j], _ = strconv.Atoi(dataS[j])
		}
		s[i] = dataI[1:]
	}
	line, _, _ := reader.ReadLine()

	_ = strings.Split(string(line), " ")

	ans := 0
	for i := 0; i < int(math.Pow(2, float64(N))); i++ {
		t := strings.Split(fmt.Sprintf("0%0"+NS+"b", i), "")
		ok := true
		for j := 1; j <= M; j++ {
			total := 0
			for k := range s[j] {
				if t[s[j][k]] == "1" {
					total += 1
				}
			}
			if total%2 != 1 {
				ok = false
				break
			}
		}
		if ok {
			ans += 1
		}
	}
	fmt.Println(ans)

}