import java.math.*

fun main(args: Array<String>) {
    val INF = 1000000000

    val (N, M) = readInputLine().split(" ").map { it.toInt() }
    
    // (価格, 開けられる宝箱のbit)
    val keys = Array(M) {
        val (a, b) = readInputLine().split(" ").map { it.toInt() }
        var bit = 0
        for (c in readInputLine().split(" ").map { it.toInt() - 1 }) {
            bit = bit or (1 shl c)
        }
        Pair(a, bit)
    }
    
    val boxBits = bits(N)
    
    val dp = IntArray(boxBits + 1) { INF }
    dp[0] = 0
    
    for (k in keys) {
        for (i in 0..boxBits) {
            dp[i or k.second] = Math.min(dp[i or k.second], dp[i] + k.first)
        }
    }

    println(if (dp[boxBits] != INF) dp[boxBits] else -1)
}

fun readInputLine(): String {
    return readLine()!!
}

fun bits(x: Int): Int {
    var ret = 1
    
    for (i in 1..x) {
        ret *= 2
    }
    
    return ret - 1
}
