import java.util.*
import kotlin.comparisons.*

fun main(args : Array<String>) {
  val (n, m) = readLine()!!.split(' ').map(String::toInt)
  val ss = (1..m).map { readLine()!!.split(' ').drop(1).map { it.toInt() - 1 } }
  val pp = readLine()!!.split(' ').map(String::toInt)

  val t = Math.pow(2.0, n.toDouble()).toInt()
  val ans = (0..t).count { i ->
    ss.withIndex().all { s ->
      pp[s.index] == s.value.map { (i shr it) and 1 }.sum() % 2
    }
  }
  println(ans)
}
