fun main(args: Array<String>) = yorukatsu9e()

fun yorukatsu9e() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val keys = Array(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        val cList = readLine()!!.split(' ').map { it.toInt() }
        val canOpen = cList.map { 1 shl (it - 1) }.reduce { acc, i -> acc or i }
        Key(a, canOpen)
    }

    val inf = Long.MAX_VALUE / 1000
    val dp = LongArray(10000) { inf }
    dp[0] = 0

    for ((price, canOpen) in keys) {
        for (box in 0 until (1 shl n)) {
            val or = box or canOpen
            dp[or] = Math.min(dp[or], dp[box] + price)
        }
    }

    val answer = dp[(1 shl n) - 1].let { if (it < inf) it else -1 }

    println(answer)
}

private data class Key(val price: Int, val canOpen: Int)
