Algorithm


C. Games with Rectangle
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In this task Anna and Maria play the following game. Initially they have a checkered piece of paper with a painted n × m rectangle (only the border, no filling). Anna and Maria move in turns and Anna starts. During each move one should paint inside the last-painted rectangle a new lesser rectangle (along the grid lines). The new rectangle should have no common points with the previous one. Note that when we paint a rectangle, we always paint only the border, the rectangles aren't filled.

Nobody wins the game — Anna and Maria simply play until they have done k moves in total. Count the number of different ways to play this game.

Input

The first and only line contains three integers: n, m, k (1 ≤ n, m, k ≤ 1000).

Output

Print the single number — the number of the ways to play the game. As this number can be very big, print the value modulo 1000000007 (109 + 7).

Examples
input
Copy
3 3 1
output
Copy
1
input
Copy
4 4 1
output
Copy
9
input
Copy
6 7 2
output
Copy
75
Note

Two ways to play the game are considered different if the final pictures are different. In other words, if one way contains a rectangle that is not contained in the other way.

In the first sample Anna, who performs her first and only move, has only one possible action plan — insert a 1 × 1 square inside the given 3 × 3 square.

In the second sample Anna has as much as 9 variants: 4 ways to paint a 1 × 1 square, 2 ways to insert a 1 × 2 rectangle vertically, 2 more ways to insert it horizontally and one more way is to insert a 2 × 2 square.



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <cstdio>
#include <vector>
typedef long long ll;

int main(){

    const ll MOD = 1000000007;
    const ll N = 2007;

    std::vector<std::vector < ll> > f(N, std::vector<ll>(N, 0));
    for(int p = 0; p < N; p++){
        f[p][0] = 1;
        for(int q = 1; q <= p; q++){f[p][q] = (f[p - 1][q - 1] + f[p - 1][q]) % MOD;}
    }

    ll n, m, k; scanf("%lld %lld %lld", &n, &m, &k); 
    printf("%lld\n", f[n - 1][2 * k] * f[m - 1][2 * k] % MOD);

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 3 1

Output

x
+
cmd
1
Advertisements

Demonstration


Codeforces Solution-C. Games with Rectangle-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+