fun main(args: Array<String>) {
    fun read() = readLine()!!
    fun readInts() = read().split(" ").map { it.toInt() }

    data class Key(val ai: Int, val ci: List<Int>)

    val (n, m) = readInts()
    val arr = Array(m) {
        val (a, b) = readInts()
        val c = readInts()
        Key(a, c)
    }

    val dp = Array(m + 1) {
        IntArray(1 shl n) { -1 }
    }

    fun makePattern(ci: List<Int>): Int {
        var retV = 0
        ci.map { it - 1 }.forEach {
            retV = retV or (1 shl it)
        }
        return retV
    }

    dp[0][0] = 0
    for (i in 1..m) {
        val (ai, ci) = arr[i - 1]
        val myPattern = makePattern(ci)
        dp[i] = dp[i - 1].clone()
        for (pattern in 0 until (1 shl n)) {
            if (dp[i - 1][pattern] == -1) continue
            if (dp[i][pattern or myPattern] == -1) {
                dp[i][pattern or myPattern] = dp[i - 1][pattern] + ai
            } else {
                dp[i][pattern or myPattern] = Math.min(dp[i - 1][pattern] + ai, dp[i][pattern or myPattern])
            }
        }
    }

    println(dp[m][(1 shl n) - 1])
}