fun main(args: Array<String>) {
    val mod = 1000000007
    val (N,M) = readIntList()
    var dp = IntArray(2.pow(N)) { 10000000 }
    dp[0] = 0

    for (m in 0 until M) {
        val dpNext = dp.toList().toIntArray()
        val (a,b) = readIntList()
        val c = readIntList().sumBy { 2.pow(it-1) }

        for (n in 0 until 2.pow(N)) {
            dpNext[n or c] = Math.min(dpNext[n or c], dp[n]+a)
        }
        dp = dpNext
    }

    var ans = dp.last()
    if (ans == 10000000) ans = -1
    println(ans)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun Int.pow(n:Int) = Math.pow(this.toDouble(), n.toDouble()).toInt()