Problem:
Score : 500 points

Problem Statement

We have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left. We will choose K of the squares and put a piece on each of them.

If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K, y_K), the cost of this arrangement is computed as:

\sum_{i=1}^{K-1} \sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)

Find the sum of the costs of all possible arrangements of the pieces. Since this value can be tremendous, print it modulo 10^9+7.

We consider two arrangements of the pieces different if and only if there is a square that contains a piece in one of the arrangements but not in the other.

Constraints

2 \leq N \times M \leq 2 \times 10^5

2 \leq K \leq N \times M

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M K

Output

Print the sum of the costs of all possible arrangements of the pieces, modulo 10^9+7.

Sample Input 1

2 2 2

Sample Output 1

8

There are six possible arrangements of the pieces, as follows:

((1,1),(1,2)), with the cost |1-1|+|1-2| = 1

((1,1),(2,1)), with the cost |1-2|+|1-1| = 1

((1,1),(2,2)), with the cost |1-2|+|1-2| = 2

((1,2),(2,1)), with the cost |1-2|+|2-1| = 2

((1,2),(2,2)), with the cost |1-2|+|2-2| = 1

((2,1),(2,2)), with the cost |2-2|+|1-2| = 1

The sum of these costs is 8.

Sample Input 2

4 5 4

Sample Output 2

87210

Sample Input 3

100 100 5000

Sample Output 3

817260251

Be sure to print the sum modulo 10^9+7.

Solution in Scala (2.11.7) (judge verdict: Wrong Answer)

import java.util.Scanner

object Main {

  case class RR(representative: Long) extends AnyVal {
    def +(that: RR): RR = RR((this.representative + that.representative) % RR.mod)

    def -(that: RR): RR = RR((this.representative - that.representative + RR.mod) % RR.mod)

    def *(that: RR): RR = RR((this.representative * that.representative) % RR.mod)

    def unary_- : RR = RR((-this.representative + RR.mod) % RR.mod)
  }


  object RR {
    val mod: Long = (1e9 + 7).toLong

    val _0: RR = RR(0)
    val _1: RR = RR(1)
  }

  def read() = {
    val sc = new Scanner(System.in)
    val n, m, k = sc.nextInt()
    (n, m, k)
  }

  def comb(a: Int, b: Int): Int = {
    if (a < b) 0
    else if (b == 0) 1
    else comb(a - 1, b - 1) + comb(a - 1, b)
  }

  def fracRR(n: Int): RR = (1 to n).map(RR(_)).foldLeft(RR(1))(_ * _)


  def combRR(n: Int, r: Int): RR = {
    // comb(n,r) = n!/(r! (n-r)!)
    val x = fracRR(n) // n!
    val y = fracRR(r) // r!
    val z = fracRR(n - r) // (n-r)!

    val yz = y * z
    x * rrInv(yz)
  }

  def mypow(x: Long, t: Long): Long = {
    if (t == 0) {
      return 1
    }
    val y = mypow(x, t / 2)
    if (t % 2 == 0) {
      y * y
    } else {
      x * y * y
    }
  }

  def mypowRR(x: RR, t: Long): RR = {
    if (t == 0) {
      return RR(1)
    }
    val y = mypowRR(x, t / 2)
    if (t % 2 == 0) {
      y * y
    } else {
      x * y * y
    }
  }

  def rrInv(x: RR): RR = mypowRR(x, RR.mod - 2)

  def solve(h: Int, w: Int, k: Int): Int = {
    // 1 + 2 + ... + tを求める
    def sum(t: Int) = t * (t + 1) / 2

    def sumDist(x: Int, y: Int): Int = {
      // 0-origin
      // xより左側: [0,x) (xマス)
      // xより右側: [x+1,w) (w-x-1マス)
      // yより上側: [0,y) (yマス)
      // yより下側: [y+1, h) (h-y-1マス)
      (sum(x) + sum(w - x - 1)) * h + (sum(y) + sum(h - y - 1)) * w
    }

    comb(w * h - 2, k - 2) * (for (y <- 0 until h; x <- 0 until w) yield sumDist(x, y) / 2).sum
  }

  def solve2(h: Int, w: Int, k: Int): Long = {
    // 1 + 2 + ... + tを求める
    def sum(t: Long) = t * (t + 1) / 2

    def sumDist(x: Long, y: Long): Long = {
      // 0-origin
      // xより左側: [0,x) (xマス)
      // xより右側: [x+1,w) (w-x-1マス)
      // yより上側: [0,y) (yマス)
      // yより下側: [y+1, h) (h-y-1マス)
      (sum(x) + sum(w - x - 1)) * h + (sum(y) + sum(h - y - 1)) * w
    }

    val result = combRR(w * h - 2, k - 2) * RR((for (y <- 0 until h; x <- 0 until w) yield sumDist(x, y) / 2).sum)
    result.representative
  }

  def main(args: Array[String]): Unit = {
    val (n, m, k) = read()
    println(solve2(n, m, k))
  }
}