import javax.swing.border.EmptyBorder

fun main(args:Array<String>):Unit{
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    f(n, m)
}
tailrec fun f(n:Int, m:Int):Unit{
    if (n != 0 && m != 0){
        val maxHighScore = Array(n){0}
        val minLowScore = Array(n){0}
        for (i in 1 .. m){
            val args = readLine()!!.split(' ').map(String::toInt).toIntArray()
            for (idx in 2 until args.size){
                maxHighScore[args[idx] - 1] += args[0]
            }
            if (args[1] == 1) minLowScore[args[2] - 1] += args[0]
        }
        val min = minLowScore.mapIndexed { index, i -> Man(index, i) }.sortedBy(Man::score)
        val max = maxHighScore.mapIndexed{index, i -> Man(index, i)}.sortedByDescending(Man::score)
        if (max.first().number != min.first().number){
            println(max.first().score - min.first().score + 1)
        }else{
            println(max(max.first().score - min[1].score, max[1].score - min.first().score) + 1)
        }
        val (nn, mm) = readLine()!!.split(' ').map(String::toInt)
        f(nn, mm)
    }
}
fun max(a:Int, b:Int):Int = if (a > b) a else b
data class Man(val number:Int, val score:Int)
