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
    }
  }


  //
  def toKey(lst: Array[Boolean]): Int = {
    var res = 0
    for (i <- 1 to N) {
      if(lst(i)) {
        res += 1 << (i-1)
      }
    }
    res
  }

  def toArray(key: Int): Array[Boolean] = {
    val res = new Array[Boolean](N+1)
    res(0) = true

    var i = 1
    var k = key
    while (k > 0) {
      if(k%2 == 1)
        res(i) = true
      k /= 2
      i += 1
    }

    res
  }

  //var hash = Map[String, Int]() // (opened, price)
  val imax = Int.MaxValue
  var hash = Array.fill[Int](1<<N)(imax)
  hash(0) = 0

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

    for (opened <- 0 until 1<<N) {
      if (hash(opened) != imax) {
        val price = hash(opened)

        val hoge = toArray(opened)
        for (k <- 1 to b(i)) {
          val ind = c(i)(k)
          if(!hoge(ind))
            hoge(ind) = true
        }
        val key = toKey(hoge)

        val nowPrice = price + a(i)

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

      }
    }

    hash = nextHash
  }
  
  
  var ans = -1
  val k = (1<<N) - 1
  if(hash(k) != imax)
    ans = hash(k)

//  println(hash.deep)
  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()
  }
}
