import scala.io.StdIn object Main { def main(args: Array[String]): Unit = { val w, h, n = StdIn.readInt var ans = 0 var ss = Set[Int]() var ks = Set[Int]() for (i <- (0 until n)) { val Array(s, k) = StdIn.readLine().split(' ').map(_.toInt) if (! ss(s)) ans += h - 1 - i if (! ks(k)) ans += w - 1 - i ss += s ks += k } println(ans) } }