import scala.io.StdIn._
import Math._

object Main extends App {
  val max = 100100100
  val Array(n, m) = readLine().split(" ").map(_.toInt)
  val dp = Array.fill(1 << n){max}
  dp(0) = 0
  for(_ <- 1 to m) {
    val Array(a, b) = readLine().split(" ").map(_.toInt)
    var c = readLine().split(" ").map(_.toInt).foldLeft(0)(_ | 1 << _ - 1)
    for(i <- (1 << n) - 1 to 0 by -1) {
      val j = i | c
      dp(j) = min(dp(j), dp(i) + a)
    }
  }
  val ans = dp((1 << n) - 1)
  println(if (ans == max) -1 else ans)
}