fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (h, w) = intList()
    val n = readLine()?.toInt() ?: return
    val a = intList()

    buildString {
        val v = mutableListOf<String>()
        var isOdd = false
        repeat(n) { index ->
            val aa = a[index]
            val value = "${index + 1}"
            repeat(aa) {
                v.add(value)
                if (v.size == w) {
                    if (!isOdd) {
                        appendln(v.joinToString(separator = " "))
                    } else {
                        appendln(v.reversed().joinToString(separator = " "))
                    }
                    isOdd = !isOdd
                    v.clear()
                }
            }
        }
    }.let {
        println(it.trimIndent())
    }
}
