fun main(args:Array<String>?): Unit {
    val (n, _) = readLine()!!.trim().split(' ').map(String::toInt)
    var sum = 0L
    for (i in 0 until n) {
        println("lst $i")
        sum += readLine()!!.trim().split(' ').first().toLong().let{b -> b * (b - 1)}
    }
    println("ans $sum")
}
