import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val a = new Array[Int](M+1)
  val b = new Array[Int](M+1)
  val c = Array.ofDim[Int](M+1, N+1)
  for (i <- 1 to M) {
    val _a, _b = in.next().toInt
    a(i) = _a; b(i) = _b
    for (k <- 1 to _b) {
      c(i)(k) = in.next().toInt
    }
  }


  //
  var hash = Map[List[Boolean], Int]() // (opened, price)
  val hoge = Array.fill[Boolean](N+1)(false)
  hoge(0) = true
  hash += (hoge.toList -> 0)


  for (i <- 1 to M) {
    val nextHash = hash.clone

    for ((opened, price) <- hash) {
      val hoge = opened.toArray
      for (k <- 1 to b(i)) {
        val ind = c(i)(k)
        if(!hoge(ind))
          hoge(ind) = true
      }
      val key = hoge.toList

      if (!nextHash.contains(key)) {
        nextHash += (key -> (price + a(i)))
      }
      else {
        val nowPrice = price + a(i)

        if (nowPrice < nextHash(key)) {
          nextHash(key) = nowPrice
        }
      }
    }

    hash = nextHash
  }

  
  var ans = -1
  val k = List.fill[Boolean](N+1)(true)
  if(hash.contains(k))
    ans = hash(k)

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
