data class Key(val a: Int, val b: Int, val c: Long) {
    constructor(a: Int, b: Int, c: List<Int>) : this(a, b, c.fold(0L){ acc, i ->  acc or (1L shl (i - 1)) })
}


fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val keys = mutableListOf<Key>()
    for (m in 0 until M) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        val c = readLine()!!.split(" ").map { it.toInt() }
        keys.add(Key(a, b, c))
    }
    val ans = calc(N, M, keys)
    println(ans)
}


fun calc(N: Int, M: Int, keys: List<Key>): Int {
    val maxN = Math.pow(2.0, N.toDouble()).toLong() - 1
    val Ns = mutableMapOf(*(0L..maxN).map { it to Int.MAX_VALUE }.toTypedArray())
    Ns[0L] = 0
    for (n in Ns.keys){
        for (key in keys){
            if (Ns[n] == Int.MAX_VALUE){
                continue
            }
            val nextKey = n or key.c
            Ns[nextKey] = Math.min(Ns[nextKey]!!, Ns[n]!!.plus(key.a))
        }
    }
    return if(Ns[maxN] == Int.MAX_VALUE) -1 else Ns[maxN]!!
}


