
fun main(args: Array<String>) {
    val (row, col, k) = getInts()

    val all = HashMap<Int, HashMap<Int, Int>>()

    val r = HashMap<Int, Int>()
    val c = HashMap<Int, Int>()
    repeat(k) {
        val (x, y) = getInts()
        r[x] = (r[x] ?: 0) + 1
        c[y] = (c[y] ?: 0) + 1

        if (all[x] == null) {
            all[x] = HashMap<Int, Int>()
        }
        all[x]!![y] = 1
    }

    val rr = r.map { it.value to it.key }.sortedByDescending { it.first }
    val rrr = rr.takeWhile { it.first == rr.first().first }
    val cc = c.map { it.value to it.key }.sortedByDescending { it.first }
    val ccc = cc.takeWhile { it.first == cc.first().first }

    rrr.forEach {r0 ->
        ccc.forEach { c0 ->
            if (all[r0.second]?.get(c0.second) == null) {
                println(r0.first + c0.first)
                return
            }
        }
    }
    println(rrr.first().first + ccc.first().first - 1)
}


fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }

